Could you describe what generic type inference is and what will be the output of this program?
class Program
{
static void SomeMethod(object parameter)
{
Console.WriteLine("Hello");
}
static void SomeMethod<T>(T parameter)
{
Console.WriteLine("World");
}
static void Main(string[] args)
{
object obj = "x";
string s = "x";
SomeMethod(obj);
SomeMethod(s);
}
}
}
Experience Level: Not defined
Tags: .NETC#Code challenge
Answer
Related C# job interview questions
What is variable capturing good for and how does it work?
.NETC# Not definedWhat will be the output of the following code that is using delegates?
.NETC#Code challenge Not definedWhat is the difference between IEnumerable and IQueryable?
.NETC#Entity FrameworkLINQPerformance Not definedWhat is boxing and unboxing?
.NETC#Performance Not definedDo you use generics? What are they good for? And what are constraints and why to use them?
.NETC#Performance Not defined