難道真的只有一種方法嗎?最近剛好找到關鍵字 ref,一個可以用在方法宣告上把參數變成傳址的方式。突然有點想哭的感覺,這就是熟悉感阿阿阿阿阿!!!
code :
class Program
{
static void Main( string[] args )
{
int refValu = 0;
PrintText( ref refValu );
PrintText( ref refValu );
PrintText( ref refValu );
Console.ReadKey( true );
}
static void PrintText( ref int count )
{
Console.WriteLine( count );
count++;
}
}