如何製作 List

第一種方法是直接使用 Dictionary<int , string> diList = new Dictionary<int , string>();

這樣就可以使用 diList.Add("1" , "One");

但是這邊會有個問題 也就是一次要加入三個可能會有點問題
因此這時候可能會用到這個

public struct Data{
    public Data(int intValue , string strValue){
        intData = intValue;
        strValue = strData;
    }
    public int intData{ get; set; }
    public string strData { get; set; }
}

這樣就可以使用 List<Data> lsData = new List<Data>();

參考:https://stackoverflow.com/questions/19231460/define-a-list-like-listint-string

留言

這個網誌中的熱門文章

無法載入檔案或組件 'System.IO.Compression' 或其相依性的其中之一。

MongoDB 入門

javascript 更改屬性及創建標籤