Are ValueTuples suitable as dictionary keys?

Yes, that’s fine. The ValueTuple<…> family is a well-defined set of regular structs with the correct equality and hash-code behaviour to work as dictionary keys. There is a slight caveat in that they are mutable rather than immutable, but that doesn’t really impact them in this context thanks to copy semantics (which means: you can’t … Read more

What makes ValueTuple covariant?

I believe what is actually happening here is a destructuring assignment. Tuple assignment will try to implicitly convert its components, and as it is possible to assign string to object, that is what happens here. The language supports assignment between tuple types that have the same number of elements, where each right-hand side element can … Read more

Check if value tuple is default

If you really want to keep it returning default, you could use result.Equals(default) the built-in Equals method of a ValueTuple should work. As of C# 7.3 value tuples now also support comparisons via == and != fully, Meaning you can now also do result == default and it should work the same.

How to create a List of ValueTuple?

You are looking for a syntax like this: List<(int, string)> list = new List<(int, string)>(); list.Add((3, “first”)); list.Add((6, “second”)); You can use like that in your case: List<(int, string)> Method() => new List<(int, string)> { (3, “first”), (6, “second”) }; You can also name the values before returning: List<(int Foo, string Bar)> Method() => … … Read more

Could not load file or assembly ‘System.ValueTuple’

ok this feels completely wrong but I cut <dependentAssembly> <assemblyIdentity name=”System.ValueTuple” publicKeyToken=”cc7b13ffcd2ddd51″ culture=”neutral” /> <bindingRedirect oldVersion=”0.0.0.0-4.0.3.0″ newVersion=”4.0.3.0″ /> </dependentAssembly> This out of my web.config for the main application. I was really just seeing what happened to see if there was an underlying dependency or something, not expecting it to run. It just carried on working, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)