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
What is disco?
Can we inherit abstract class in c#?
Why do we need to override in c#?
Explain the difference between .net and c#?
What's the difference between the debug class and trace class? Documentation looks the same.
Do vs while c#?
What is event and delegates in c#?
What is the function of .IsDescendent()?
What is collection class c#?
What does ienumerable mean?
Can arraylist store different data types in c#?
Can I define a type that is an alias of another type (like typedef in c++)?
What does args mean in c#?
Explain polymorphism in c# with a simple example?
What is the difference between list and arraylist c#?