[ACCEPTED]-Is there an equivalent C# syntax for C's inline anonymous struct definition?-equivalent

Accepted answer
Score: 16

This is not possible in C#, however you 5 can define an instance of an anonymous type 4 like this:

var x = new { SomeField = 1, SomeOtherField = "Two" }; 

This would effectively be the 3 same, giving you an instance of a type that 2 is specific to that variable and cannot 1 used outside the variable's scope.

Score: 1

Simple answer: No, it is not possible.


Score: 0

Would this not help ?

(string, string, int) retVal;
retVal.Item1 = "A String";
retVal.Item2 = "Another String"
retVal.Item3 = 4;


More Related questions