Reputation: 598
Can you declare an anonymously-typed variable with explicit casting?
For example, you can do this:
var student = new { ID = 1 , name = "Jim" };
But not this:
var student = new { int ID = 1 , string name = "Jim" };
The goal is to have a variable that is:
As for the question of 'Why?', this is more of an informational curiosity of mine. Suppose you wanted ID
to be an Int64
.
Upvotes: 2
Views: 420