Obsolete


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ObsoleteDemo
{
    /*
        //[WebMethod]
        expose a method as an XML Web service method

        //[Serializable]
        Indicates that a class can be serialized
    */
    class Program
    {
        static void Main(string[] args)
        {
            GameScoreCaculator A = new GameScoreCaculator();

            GameScoreCaculator.Sum(1, 4);
            GameScoreCaculator.Sum(8, 2, 7);
        }

        public class GameScoreCaculator
        {
            [Obsolete]
            public static int Sum(int i1, int i2)
            {
                return i1 + i2;
            }

            [Obsolete("請使用 Sum(List<int> intList) 代替")]//自定義建議說明
            //[Obsolete("請使用 Sum(List<int> intList) 代替", true)]//後面加 True 則會讓早期有呼叫該 Method 的程式碼出錯
            public static int Sum(int i1, int i2, int i3)
            {
                return i1 + i2 + i3;
            }
            public static int Sum(List<int> intList)
            {
                int Sum = 0;
                foreach (int i in intList)
                {
                    Sum += i;
                }
                return Sum;
            }
        }
    }
}

results matching ""

    No results matching ""