???????????????????б????????????string??“??????”????????????÷???????? oldStr="New string"??????????????????????oldStr?е?"old string"??"New string"?????string??????????????????????????????·????????棬???????????е?????? “New string”??????????е???????oldStr????????????str?????? "old string"???????oldStr?????????????????? "New string"??????????????н??????????????????????????????????????????????????????

?????????????????

???????????????????????????????????????ref ??out????????????????????????????????y??д?????????????????????

??????????????????????????????????ref??out????????????????

????CLR???????out ??ref??????????????????磺

#region CLR ????out??ref????????????????
        private static void Add(string str)
        {
            Console.WriteLine(str);
        }
        // ?????????????????????????????????????????????
        private static void Add(ref string str)
        {
            Console.WriteLine(str);
        }
        #endregion

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????忴???????????????

class Program
    {
        static void Main(string[] args)
        {
            #region ?????????
            Console.WriteLine("?????????????");
            int num = 1;
            string refStr = "Old string";
            ChangeByValue(ref num);
            Console.WriteLine(num);
            changeByRef(ref refStr);
            Console.WriteLine(refStr);
            #endregion
            Console.Read();
        }
        #region ?????????
        // 1. ?????????????????
        private static void ChangeByValue(ref int numValue)
        {
            numValue = 10;
            Console.WriteLine(numValue);
        }
        // 2. ????????????????????
        private static void changeByRef(ref string numRef)
        {
            numRef = "new string";
            Console.WriteLine(numRef);
        }
        #endregion
}

???????н?????

?????????н???????????????????????????????????????????????????????°?????????????

??????????

?????????????????????????????????????????????????????????????????????????????????????????ε????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????