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
Explain the difference between a Private Assembly and a Shared Assembly
What is tuple in c#?
Why is it not a good idea to use empty destructors?
What is void method?
Is the following code legal?
What is the difference between abstract class and interface in c#?
What is overriding in c#?
What is ControlBox Propertie
What are the types of operator?
Please explain the basic string operations used in c#?
What is task parallel library?
Explain about Threading Types.
Can you change the value of a constant filed after its declaration?
What is web forms in c#?
Why do we need nullable types in c#?