How to make a class not inheritable other than sealed?
Answer Posted / lalit pradhan
Hey guys this is practically tested answer:
namespace Test
{
class Program
{
static void Main(string[] args)
{
A a = new A();
a.Method();
//B b = new B();
//b.Method("From B");
C c = new C();
Console.ReadKey();
}
}
class A
{
public void Method()
{
Console.WriteLine("From A");
}
}
static class B : A
{
public void Method(string s)
{
Console.WriteLine(s);
}
//void calculate();
}
class C : B //Here you will notice that B's color is
not highlighted to green when its not inheritable
{
public void Final()
{
Console.WriteLine("I am Final Method");
}
}
}
Enjoy!!!
Lalit Pradhan a.k.a DOTNET Gadhaa
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is string in c# net?
What is the difference between throw and throw ex?
who is a protected class-level variable available to?
Explain About stateless and state full web service
Can properties be overloaded in c#?
What does exclamation mark mean c#?
Is list immutable in c#?
what is collections in .net? why we use?
How to transpose multi-dimensional array?
What is dataadapter c#?
What is difference between out and ref in c#?
Tell me the difference between value passing and address passing?
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
How many types of inheritance are there in c#?
Write a program to find the angle between the hours and minutes in a clock