If I want to override a method 1 of class A and in class b
then how do you declare ?

Answer Posted / sridevi

declare method1 as virtual in classA and then create classB
as derived class of ClassA and override method1 in classB.

class ClassA{
public virtual add();

}

class ClassB:ClassA{
public overrride add(){

console.WriteLine("Im in derived");

}

}

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the string functions in c#?

524


Define an abstract class?

508


What is lastindexof c#?

484


Which is better interface or abstract class in c#?

445


How does bubble sort work?

508






What is the difference between // comments, /* */ comments and /// comments?

500


What is Custom attribute? How to create? If I'm having custom attribute in an assembly, how to say that name in the code?

515


How many parameters can a method have c#?

486


Can we create instance of private class in c#?

504


What is the difference between an integer and int?

476


What is Assembly. and Describe type of assembly. why most developer happy with private assembly.

580


What is the difference between array and arraylist c#?

468


What is unmannaged code and will CLR handle this kind of code or not .

592


What is difference between code access and role based security?

510


What are interfaces in c#?

518