Karthikeya Boyini has Published 2383 Articles

Write a C# program to solve FizzBuzz problem

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:52:30

232 Views

The FizzBuzz problem states that −Display "Fizz" instead of the number for each multiple of 3, Display "Buzz", instead of the number for each multiple of 5.Display "FizzBuzz", instead of the number for each multiple of 5 & 3Let us see how to implement the above using C# −Exampleusing System; ... Read More

Static vs. Non-Static method in C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:36:07

1K+ Views

Declare a member function as static. Such functions can access only static variables. The static functions exist even before the object is created.A static class cannot be instantiated and can only contain static members.Static methods is set using static keyword −public static int getNum() {    return num; }The following ... Read More

Retrieving Elements from Collection in C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:31:09

658 Views

Let us see an example of a list collection.We have set the elements −List list = new List(); list.Add(20); list.Add(40); list.Add(60); list.Add(80);Now let’s say we need to retrieve the first element from the list. For that, set the index like this −int a = list[0];The following is an example showing ... Read More

Virtual vs Sealed vs New vs Abstract in C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:28:08

3K+ Views

VirtualThe virtual keyword allows a class to be overridden. For overriding a parent class method in the child class, declare the parent class method as virtual.SealedWhen a class is declared sealed, it cannot be inherited, abstract classes cannot be declared sealed.To prevent being overridden, use the sealed in C#. When ... Read More

How to swap two numbers without using a temp variable in C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:24:18

645 Views

To swap two numbers, use the third variable and perform arithmetical operator without using a temp variable.Set two variables for swapping −val1 = 5; val2 = 10;Now perform the following operation for swap −val1 = val1 + val2; val2 = val1 - val2; val1 = val1 - val2;Exampleusing System; namespace ... Read More

Timer in C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:15:33

2K+ Views

The namespace used to set a timer is System. Timers. The Timer class generates an event after a set interval, with an option to generate recurring events.Firstly, create a timer object for 5 seconds interval −timer = new System.Timers.Timer(5000);Set elapsed event for the timer. This occurs when the interval elapses ... Read More

Private Variables in C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:12:36

5K+ Views

Private access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members. Even an instance of a class cannot access its private members.Create a private variable −private double length;Let us see an ... Read More

Mutation Test tools in C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:10:08

250 Views

One of the best tools for mutation testing in C# is “VisualMutator” It is integrated with the .NET programming environment.The following are the features of VisualMutant, which is a mutation test tool −Measure the quality of the test suite.To create first-order mutants using built-in and custom mutation operators.View modified code ... Read More

Overriding in C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:07:05

411 Views

Runtime polymorphism has method overriding that is also known as dynamic binding or late binding. It is implemented by abstract classes and virtual functions. Abstract classes contain abstract methods, which are implemented by the derived class.Let us see an example of abstract classes that implement runtime polymorphism and works with ... Read More

Priority Queues with C#

karthikeya Boyini

karthikeya Boyini

Updated on 21-Jun-2020 16:01:25

218 Views

A priority queue is held information with a priority value. It is an extension of queue.The item with the highest property is removed first when you try to eliminate an item from a priority queue.Let us see how to set priority queue −public class MyPriorityQueue where T : IComparable ... Read More

Advertisements