繁体   English   中英

添加到对列表C#

[英]Adding to a list of pairs c#

我正在尝试添加到对列表。 我已经初始化了如下列表

 public List<Tuple<string, Dictionary<string, int>>> StudentRecords = new List<Tuple<string, Dictionary<string, int>>>();

我正在创建一种添加到此列表的方法,但是它会显示一条错误消息:

方法Add不重载,带有2个参数

public void AddRecord(string studentname, Dictionary <string, int> studentMarks)
{
    StudentRecords.Add(studentname, studentMarks);
}

有人可以在这里看到我在做什么错吗?

StudentRecords是一个Tuple List 所以你必须像这样添加一个Tuple

StudentRecords.Add(Tuple.Create(studentname, studentMarks));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM