“OverloadResolutionInheritance” (Problem)
What will the following code display?
1
class Foo
2
{
3
public Foo()
4
{
5
Quux();
6
}
7
public virtual void Quux()
8
{
9
Console.WriteLine("Foo.Quux()");
10
}
11
}
12
class Bar : Foo
13
{
14
protected string name;
15
public Bar()
16
{
17
name = "Bar";
18
}
19
public override void Quux()
20
{
21
Console.WriteLine("Bar.Quux(), " + name);
22
}
23
public void Quux(params object[] args)
24
{
25
Console.WriteLine("Bar.Quux(params object[])");
26
}
27
}
28
class Baz : Bar
29
{
30
public Baz()
31
{
32
name = "Baz";
33
Quux();
34
((Foo)this).Quux();
35
}
36
}
37
void Main()
38
{
39
new Baz();
40
}
Copied!
Solution
Copy link