Exemple #1
0
    //	数値の変更
    static void changeValue()
    {
        PosClass  pc = new PosClass();
        PosStruct ps;           //値なので new しなくても使える

        pc.x = 1;
        pc.y = 0;
        ps.x = 1;
        ps.y = 5;

        Console.WriteLine("-------- 変更前");
        Console.WriteLine(pc);
        Console.WriteLine(ps);

        change(pc, ps);

        Console.WriteLine("-------- 変更後");
        Console.WriteLine(pc);          //	x=3		参照渡しなので変更は反映される
        Console.WriteLine(ps);          //	x=1		値渡しなので変更は反映されない
    }
Exemple #2
0
 //	nullは許容されるのか
 static void nullable()
 {
     PosClass pc = null;
     //PosStruct ps = null;		//	値型なので null をセットできない旨のコンパイルエラー
 }
Exemple #3
0
 static void change(PosClass pc, PosStruct ps)
 {
     pc.x = 3;
     ps.x = 3;
 }