Home > Net >  C # static method call
C # static method call

Time:09-26

Class program
{
The static void m () {}
The static void n ()} {by operation, producing k
}
In a class, want to call n method generated inside k m method, how to do

CodePudding user response:

Then you by n return values of k,
Not void

CodePudding user response:

The first: in the method body declare a variable k at the same level (assuming k type string), in the n method generated in the
 class program 
{
String k="";
The static void m () {
//call the method of n
N ();
//to use below are generated by the k k

}
The static void n ()} {by operation, producing k
}

The second: upstairs moderator said, n method return value into k type (assuming as string), rather than void
 class program 
{
The static void m () {
//aaa operations generated that k
String triple=n ();
}
The static string n ()} {by operation, producing k
}

CodePudding user response:

Class program
{
The static string k="";
Method 1
The static void m () {
//call the method of n
K=n ();
//to use below are generated by the k k
The static string n ()} {by operation, producing k

Method 2
N (ref string k);
//to use below are generated by the k k
}
Static void n (ref k)} {by operation, producing k
}

Methods 3
N (out);
//to use below are generated by the k k
}
Static void n (out)} {by operation, producing k
}

CodePudding user response:

The return value can be set to k
  •  Tags:  
  • C#
  • Related