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?

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


Please Help Members By Posting Answers For Below Questions

What is a type c#?

941


What is private constructor c#?

899


What is the default value of decimal in c#?

904


How does foreach loop work in c#?

949


What exception can an overridden method throw in comparison with the method it is overriding?

859


What are collection classes?

923


What are the advantages of properties in c#?

955


What is typeof c#?

944


What is session state in asp net c# with example?

860


What is private protected in c#?

874


How do I use the 'using' keyword with multiple objects?

939


What is sqlconnection in c#?

912


What is the difference between console and windows application?

948


What is sqlcommand in c#?

881


What does convert toint32 mean?

938