コード例 #1
0
        private static void Main(string[] args)
        {
            #region Struct

            TheStruct st = new TheStruct();

            st.x = 1;

            StructTaker(st);

            Console.WriteLine(st.x); // output : 1

            #endregion Struct

            #region Class

            TheClass cs = new TheClass();

            cs.x = 1;

            ClassTaker(cs);

            Console.WriteLine(cs.x); // output : 5

            #endregion Class
        }
コード例 #2
0
 /// <summary>
 /// 改變傳遞過來結構的值
 /// </summary>
 /// <param name="s">傳遞結構</param>
 private static void StructTaker(TheStruct s)
 {
     s.x = 5;
 }