can you overload a method of class A in Class B if it is
derived class of A?If it is yes tell me how is it possible?
Answer Posted / lalit pradhan
namespace Test
{
class Program
{
static void Main(string[] args)
{
A a = new A();
a.Method();
B b = new B();
b.Method("From B");
Console.ReadKey();
}
}
class A
{
public void Method()
{
Console.WriteLine("From A");
}
}
class B : A
{
public void Method(string s)
{
Console.WriteLine(s);
}
}
}
| Is This Answer Correct ? | 15 Yes | 1 No |
Post New Answer View All Answers
How C# 4.0 supports dynamic programming language?
What is difference between string and stringbuffer in c#?
Are structs value types or reference types?
What are anonymous functions in c#?
What is a streamwriter in c#?
What is the wildcard character in sql?
What is escape character in c#?
write program in c# using this instructions name avinash varma ,work experiance<2,nochildren his work experiance is higher than 5 years,more than one children one children name is diwakar,number of years of work eperiance at current company is the ratio of children and work experiance is 0.21 to 0.5
Why do we overload constructors?
what are the contents of an assembly ?
What is the difference between dll and lib?
Can a struct inherit from another struct or class in c#?
What are escape sequences explain with example?
Can non-default constructors be used with single call sao?
Is enum a value type c#?