Hello, I'm working with C # and read about literal tuples. With this, I'm creating the class below:
public class Foo
{
public (int bar, string bin)? barBin { get; set; }
}
In theory, for me to be able to use this class and assign values to this tuple, I would do it like this:
int testBar = 2;
string testBin = "hello world";
var foo = new Foo()
{
barBin = (bar: testBar, bin: testBin)
};
The problem is that when I use this statement VS gives me the message An expression tree may not contain a tuple literal
. I also tried to pass an undeclared tuple ( barBin = (testBar, testBin)
) but it does not work.
How do I use literal tuples as properties in a class and work on them?