Answer: List<object> objCollection = new List<object>() { 10, 20, null, "hello", 12.5 };
foreach (object o in new List<object>() { 10, 20, null, "hello", 12.5 })
{
if (o is *)
{
Console.WriteLine("It's a match for {0}",o);
}
}
It's obvious from the program that, * is the wild card that matches all the types. This is Wildl Card based Pattern Matching in C# 7.0
Asked In: Many Interviews |
Alert Moderator