alan2here
alan2here

Reputation: 3317

List of Tuple trouble

edit: solved, sorry about this, was due to a typo.


This code.

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

Produces the following error for a.Add(b)

The best overloaded method match for
'System.Collections.Generic.List<System.Tuple<short,short>>
.Add(System.Tuple<short,short>)'
has some invalid arguments.

In short

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

I can't see how this is.

Upvotes: 1

Views: 534

Answers (4)

Masa
Masa

Reputation: 311

Tuple<Int16, Int16> and Tuple<UInt16, UInt16> are two different type of tuple.

Upvotes: 4

dtb
dtb

Reputation: 217313

You are trying to add an UInt16 pair to a list of Int16 pairs. That doesn't work.

You can add an Int16 pair to a list of Int16 pairs:

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

Upvotes: 3

lukiffer
lukiffer

Reputation: 11303

UInt is not an Int

Reference: http://msdn.microsoft.com/en-us/library/yht2cx7b.aspx

Upvotes: 1

OnResolve
OnResolve

Reputation: 4032

It's telling you exactly the problem and the solution. Try the short instead of unsigned short

Upvotes: 0

Related Questions