Call to Method: Static: Address is assigned only once ... Static members are generated with the class, so when there are static members, non-static members are not yet generated, so they cannot be called to the
If the static keyword is added to the method, then it is still a non-static method
Ina method in the same classInvocation of:
1. Static can be directly called static, the current class can omit the class name
2. Static can not directly call non-static--Static Mr.
3. Non-static can be directly called static
4. If the static need to call a non-static member must use an instance member
5. Non-static can be directly non-static
methods of different classesCall:
1. Static use of the class. Static members
2. Non-static members use the class's instance object object. Method ()
Example:
public class Program
{
static void Main (string[] args)
{
Meditation method
#region Call method
int maxnum = Getmax (NUM1, num2);
Console.WriteLine ("Maximum value is {0}", Maxnum);
#endregion
Non-Silent
#region call the non-static method
Program model = new program ();
Model.test (NUM1, num2);
#endregion
}
#region ********** to obtain the maximum of two numbers (Trinocular operation) **********
<summary>
Get the maximum value of two numbers
</summary>
<param name= "NUM1" > First value </param>
<param name= "num2" > Second value </param>
<returns></returns>
public static int Getmax (int num1, int num2)
{
return NUM1 > num2? num1:num2;
}
#endregion
#region ********** The maximum value (non-static) of the two numbers **********
public void Test (int num1, int num2)
{
Non-static method for surface adjustment
int Maxnum=getmax (NUM1, num2);
Console.WriteLine ("Maximum value is {0}", Maxnum);
}
#endregion
}
The call to the C # method says