1. 程式人生 > >c# 方法返回多個值用out

c# 方法返回多個值用out

該方法返回   a+10   和   a-10   的結果,返回兩個值:

public  static  void  GetValue( int a , out int b , out int c )

{

    b = a+10;

    c = a-10;

}

呼叫該方法:

int  a = 100;

int  b;

int  c;

GetValue( a , out b , out c );

Console.WriteLine( b );

Console.WriteLine( c );

Console.ReadKey();