0

我有一个多维数组,其中存储有关要见面的人的姓名、时间和日期的信息。调度程序的一种。我如何接受新的详细信息并通过添加新的行和列来存储新信息。

4

1 回答 1

0

我建议您将 替换Multidimensional ArrayDictionary( see this )
使用Dicitonary<K, V>您将能够添加“新行”(准确地说是KeyValuePairs<K, V>see this))、查找、删除和修改。它们以独特的方式表示Key,会给您带来价值。
例如:

public class Program {
    public void Main() {
        Dictionary<int, Meeting> meetingDictionary 
             = new Dictionary<int, Meeting>(); //`int` on the left will be the key, and `Meeting` on the right is the value

            //int represents a unique Id of the meet event.
            //To add a new meeting:
            var date = new DateTime(2013, 7, 21); //date representor of the meet
            var meetingA = new Meeting("Obamba Blackinson", date); //object to hold this data.
            meetingDictionary.Add(1, meetingA); //note that Id can change to anything you wish, for example a string of the person's name.

            //How to pull it out of dictionary:
            var meetWithObamba = meetingDictionary[1];

            //**do w/e with the meet**. any modifications of meetWithObamba will edit the item in the dictionary too.
        }
    }

    public class Meeting {
        string PersonName;
        DateTime MeetingDate;

        public Meeting(string name, DateTime date) {
            PersonName = name;
            MeetingDate = date;
        }
    }
}

或者,如果您愿意,您可以尝试使用List<V>请参阅此)解决它,它还可以删除、添加和修改特定类型“包”中的项目 ''。
如果您不了解其<T>含义,请参阅泛型

于 2013-07-28T00:32:36.410 回答