Reputation: 14624
what word can i write to access static function inside class? like self:: in php?
Upvotes: 3
Views: 276
Reputation: 2987
public class Discover
{
static int myVariable = 1;
public Discover()
{
var test = myVariable;
}
}
Upvotes: 0
Reputation: 558
If your static class is named etc. SampleClass, you can access its functions with SampleClass.YourFunction(); . If you want to call a function in other static method, just use the name of the function .
Upvotes: 0
Reputation: 26952
Write the name of the class. For example:
public static class MyClass {
public static void HelloWorld(){}
}
And use it like:
MyClass.HelloWorld();
Upvotes: 0
Reputation: 437854
There is no such keyword in C#. You need to use the class name, e.g.
MyClass.StaticMember
Upvotes: 2
Reputation: 29668
You just use the type name:
static class Test
{
public static string GetSomething()
{
return "Something";
}
}
string s = Test.GetSomething();
If you're in the class already you just call the method.
Upvotes: 4
Reputation: 9563
Simply use StaticMethodName(...)
(when inside the class where the static method is defined) or ClassName.StaticMethodName(...)
.
Upvotes: 2