Give an example of a Wildl Card based Pattern Matching in C# 7.0

 Posted by Rajnilari2015 on 6/23/2016 | Category: C# Interview questions | Views: 1954 | Points: 40
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 

Comments or Responses

Login to post response