MCQs > IT & Programming > C# > What will be the output of the following code: public delegate void TestDel(); class Program { static void Main(string[] args) { Program prog = new Program(); Foo foo = prog.FooGetter(); if (object.Equals(foo, null)) { Console.WriteLine("Uh-oh, something went wrong"); } else { Console.WriteLine(foo.x.ToString()); } Console.ReadLine(); } public Foo FooGetter() { Foo result = null; Bar bar = new Bar(); bar.TestDel += async () => { result = await Foo.GetFoo(); }; bar.DoStuff(); return result; } } public class Foo { public int x { get; set; } public async static Task<Foo> GetFoo() { //Code omited. This method takes approx 3 seconds //to run. This will ALWAYS return a Foo object with an //x value of 1. } } public class Bar { public event TestDel TestDel; public void DoStuff() { TestDel.Invoke(); } }

C# MCQs

What will be the output of the following code: public delegate void TestDel(); class Program { static void Main(string[] args) { Program prog = new Program(); Foo foo = prog.FooGetter(); if (object.Equals(foo, null)) { Console.WriteLine("Uh-oh, something went wrong"); } else { Console.WriteLine(foo.x.ToString()); } Console.ReadLine(); } public Foo FooGetter() { Foo result = null; Bar bar = new Bar(); bar.TestDel += async () => { result = await Foo.GetFoo(); }; bar.DoStuff(); return result; } } public class Foo { public int x { get; set; } public async static Task<Foo> GetFoo() { //Code omited. This method takes approx 3 seconds //to run. This will ALWAYS return a Foo object with an //x value of 1. } } public class Bar { public event TestDel TestDel; public void DoStuff() { TestDel.Invoke(); } }

Answer

Correct Answer: "Uh-oh, something went wrong"

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

More C# MCQ Questions

search

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it