C# 元组故障列表

C# 元组故障列表,c#,list,collections,tuples,abstraction,C#,List,Collections,Tuples,Abstraction,编辑:已解决,对此表示抱歉,是因为输入错误 这个代码 List<Tuple<Int16, Int16>> a = new List<Tuple<Int16, Int16>>(); Tuple<UInt16, UInt16> b = Tuple.Create<UInt16, UInt16>(4, 2); a.Add(b); 总之 List<Tuple<short,short>>.Add(Tuple&l

编辑:已解决,对此表示抱歉,是因为输入错误

这个代码

List<Tuple<Int16, Int16>> a = new List<Tuple<Int16, Int16>>();
Tuple<UInt16, UInt16> b = Tuple.Create<UInt16, UInt16>(4, 2);
a.Add(b);
总之

List<Tuple<short,short>>.Add(Tuple<short,short>)
has invalid arguments

我看不出这是怎么回事。

它准确地告诉了你问题和解决方案。试试短的而不是不带符号的短的

它会准确地告诉你问题和解决方案。请尝试使用short而不是unsigned short

UInt不是Int

参考:

UInt不是Int

参考:

您正试图将UInt16对添加到Int16对列表中。那不行

可以将Int16对添加到Int16对列表中:

您正在尝试将UInt16对添加到Int16对的列表中。那不行

可以将Int16对添加到Int16对列表中:


Tuple和Tuple是两种不同类型的Tuple。

Tuple和Tuple是两种不同类型的Tuple。

@dtb:这就是答案。要么你回答这个问题,要么我们关闭它,因为这一定是重复的:-@dtb:这就是答案。您要么回答问题,要么我们将其关闭,因为这必须是重复的:-
List<Tuple<short,short>>.Add(Tuple<short,short>)
has invalid arguments
List<Tuple<Int16, Int16>> a = new List<Tuple<Int16, Int16>>();
Tuple<Int16, Int16> b = Tuple.Create<Int16, Int16>(4, 2);
a.Add(b);