I'm finding that ValueTuples evaluate differently when I access their properties from a collection.
public static List<Tuple<string, bool>> MyTupleList = new List<Tuple<string, bool>>
{
new Tuple<string, bool>("test", true)
};
public static List<(string b, bool c)> MyList = new List<(string b, bool c)>
{
("test", true)
};
Why do these two highlighted lines evaluate differently and how can I change "MyList[0].c" to get the value correctly?
MyTupleList
related which is not aValueTuple
? – SempachMyList[0].c
yields the wrong value) or is this just a problem with the Visual Studio tool window? If the latter: This is a Visual Studio issue (and not a C# issue), so please include the precise VS version in your question and tag it withvisual-studio-{version}
. If the former: Please provide a full repro example. Oh, and good question, by the way! – InhabitedImmediate Window
and other tooling (Watch Window
etc) - it doesn't affect the app itself. I can repro it in VS 15.8.4, .NET Core 2.1. – Pruittc
inMyList[0].c
with the debugger: "'System.ValueTuple<string,bool>' does not contain a definition for 'c' and no extension method 'c' accepting a first argument of type 'System.ValueTuple<string,bool>' could be found (are you missing a using directive or an assembly reference?) " – SempachMyList[0].b
orMyList[0].c
as the Watch expression. – Celebes123
forItem1
and"abc"
forItem2
. .NET version: 4.7.03056, Language Level: C# 7.2 – Sempach