In C# you can write
var x = "hello";
Since "hello" is a string, x becomes a string at compile time. This is called type inference. (As in, the type of variable x got inferred.)
If you try something like
var x = "hello";
int b = a;
The compiler will throw an error: Cannot
implicitly convert type 'int' to 'string'.
No comments:
Post a Comment
Comments will appear once they have been approved by the moderator