What will be the output of the following C# code?
{
delegate string f(string str);
class sample
{
public static string fun(string a)
{
return a.Replace('k', 'o');
}
}
class Program
{
static void Main(string[] args)
{
f str1 = new f(sample.fun);
string str = str1("Test Ykur C#.NET Skills");
Console.WriteLine(str);
Console.ReadLine();
}
}
}
{
delegate string f(string str);
class sample
{
public static string fun(string a)
{
return a.Replace('k', 'o');
}
}
class Program
{
static void Main(string[] args)
{
f str1 = new f(sample.fun);
string str = str1("Test Ykur C#.NET Skills");
Console.WriteLine(str);
Console.ReadLine();
}
}
}A. Test Ykur C#.NET Skills
B. Test Ykour C#.NET Skills
C. Test Your C#.NET Skills
D. Test ur C#.NET Skills
Answer: Option C
Related Questions on Delegates and Events in C Sharp
What is the purpose of the GetInvocationList() method associated with delegates in C#?
A. Removes a delegate from the current delegate
B. Adds a new delegate to the current delegate
C. Invokes all the delegates bound to the current delegate
D. Retrieves an array of delegates bound to the current delegate
What is a callback function in the context of delegates and events in C#?
A. A function that is called when an event is raised
B. A function that is called to subscribe to an event
C. A function that is called to unsubscribe from an event
D. A function that is called to handle an event
A. Func
B. Predicate
C. Action
D. EventHandler

Join The Discussion