B
BenTam
Guest
Dear All,
I copy the following code from the book "Introduction to CSharp 8". However the employee () is red lined. What is the type of "Employee ()", an array, collection, a class, or a method?
The source code is as follows.
var bassam = new Employee () { Age = 42 , Name = "Bassam" };
var thomas = new Employee () { Age = 43 , Name = "Thomas" };
var obj = new object ();
Console.Console.WriteLine ( GetEmployee ( bassam ));
Console.WriteLine ( GetEmployee ( thomas ));
Console.WriteLine ( GetEmployee ( obj ));
static string GetEmployee ( object o ) => o switch
{Employee p when p.Age == 42 && p.Name== "Bassam" => $ "{p.Name} Alugili",
Employee p => $ "{p.Name} Albrecht",
_ => "unknown"};
Continue reading...
I copy the following code from the book "Introduction to CSharp 8". However the employee () is red lined. What is the type of "Employee ()", an array, collection, a class, or a method?
The source code is as follows.
var bassam = new Employee () { Age = 42 , Name = "Bassam" };
var thomas = new Employee () { Age = 43 , Name = "Thomas" };
var obj = new object ();
Console.Console.WriteLine ( GetEmployee ( bassam ));
Console.WriteLine ( GetEmployee ( thomas ));
Console.WriteLine ( GetEmployee ( obj ));
static string GetEmployee ( object o ) => o switch
{Employee p when p.Age == 42 && p.Name== "Bassam" => $ "{p.Name} Alugili",
Employee p => $ "{p.Name} Albrecht",
_ => "unknown"};
Continue reading...