var intArray = new [] { 1, 2, 3 };
var stringArray = new [] { "hello", "world", null };
var nullableIntArray = new [] { 1, (int?)2, 3 };
Console.WriteLine(intArray.GetType());
Console.WriteLine(stringArray.GetType());
Console.WriteLine(nullableIntArray.GetType());
// Following results in a compile-time error:
// "No best type found for implicitly-typed array"
var notGoingToWorkArray = new [] { "hello", 1, 2f };
var stringArray = new [] { "hello", "world", null };
var nullableIntArray = new [] { 1, (int?)2, 3 };
Console.WriteLine(intArray.GetType());
Console.WriteLine(stringArray.GetType());
Console.WriteLine(nullableIntArray.GetType());
// Following results in a compile-time error:
// "No best type found for implicitly-typed array"
var notGoingToWorkArray = new [] { "hello", 1, 2f };
No comments:
Post a Comment