أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
In C# we does not required Object of the Static class, we can Call Directly To the Method
for Example
classname.methodname();
with the <class name>.<method name>
We just need to right the Class Name following by method name
Example :
public static class Rectangle
{
public static int CalculateArea(int width, int height)
{
return width * height;
}
}
Here to access the method CalculateArea present in class Rectangle we just need to write the following syntax
Rectangle.CalculateArea(5,4);
In C# you can call static class methods using below syntax
ClassName.MethodName
Using the class name directly without create an object from it.
ClassName.StaticMethodName();
We can call the static mehtod Through the ClassName Onwhich the Static method is member.
like MyClass.mystaticmethod();