STATIC METHOD CAN BE OVERLOADING AND OVERIDNG? IS POSSIBLE IN
iN c# .NET AND WHAT IS THE REASON??

Answer Posted / sudhir sheoran

Static Methods can't be override because static methods can only be accessed using class name and are inaccessible to the objects of the class. So no question of overriding.

But canbe overloaded. See the below example:

class Program
{
static void Main(string[] args)
{
abc.calculate(2, 3);
abc.calculate(2.0, 3.9);
Console.ReadLine();
}
}
public static class abc
{
public static void calculate(int a,int b)
{
Console.WriteLine("Int");
}
public static void calculate(double c,double d)
{
Console.WriteLine("Double");
}
}

Is This Answer Correct ?    25 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is get set in c#?

748


What is file extension of webservices?

783


What is alias in c#?

727


What is the meaning of extention?

696


How can encapsulation be achieved?

817


What is readline library?

703


What is the use of dll file in c#?

656


What is jit? What are the different types of jit?

774


Is it possible to have different access modifiers on the get/set methods of a property?

698


How do you declare a method in c#?

666


Why do we use 0?

686


What is the data encapsulation?

645


What is the difference between delegates and superdelegates?

670


What is the benefit of interface in c#?

688


Which controls do not have events?

753