Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to make a class not inheritable other than sealed?

Answers were Sorted based on User's Feedback



How to make a class not inheritable other than sealed?..

Answer / 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

How to make a class not inheritable other than sealed?..

Answer / rasik bihari

I don't agree with this (Answer # 1) as Making the class as
private will prevent it from even being initialized or
instantiated. I don't have the answer myself :-)

Is This Answer Correct ?    0 Yes 0 No

How to make a class not inheritable other than sealed?..

Answer / bikas pandey

Declare The Class Modifier As Private

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Sharp Interview Questions

How do you declare an interface in c#?

0 Answers  


Hi to everybody. Lastweek i had taken an interview on c#. They ask what is boxing & unboxing, Masking.Please tell the answer and it is useful for me.

8 Answers  


Explain what are three test cases you should go through in unit testing?

0 Answers  


What is generic types in c#?

0 Answers  


What is iqueryable and ienumerable in c#?

0 Answers  


What are the different types of comments in c#?

0 Answers  


What is concrete class in c#?

0 Answers  


if i want to transmit binary data,,,will it be support by Webservices or any exceptions ? define

2 Answers  


What is xml serialization in c#?

0 Answers  


What is private class in c#?

0 Answers  


Can an array be null c#?

0 Answers  


What language is c# similar to?

0 Answers  


Categories