When you inherit a protected class-level variable, who is it
available to?

Answer Posted / kiran

//When you inherit a protected class-level variable, who is
it available to?
//Answer is classes within the same namespace
namespace SameNamespace
{
class MyBaseClass
{
protected int myprotectedint;

}
class MyDerivedClass:MyBaseClass
{
public int GetProtectedMember()
{
return myprotectedint;
}
public MyDerivedClass(int myvalue)
{
myprotectedint = myvalue;
}

}

class MyTest
{
public static void Main()
{
MyDerivedClass mdc = new MyDerivedClass(12);

Console.WriteLine(mdc.GetProtectedMember());
Console.ReadKey();
}
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I format in c#?

497


What is difference between list and ilist in c#?

466


What is the purpose of abstract class in c#?

490


What is a protected class c#?

484


What .exe means?

504






Can int be null c#?

523


What is asax file in c#?

568


What is an example of delegation?

499


How do I open the console window?

568


Explain the different types of delegates used in c#.

507


What is a .exe extension files? How is it similar to .dll extension files?

574


What are the differences between a class and a struct?

473


What are the characteristics of c#?

472


Differentiate between method overriding from method overloading with its functionality?

534


Can you inherit multiple abstract classes in c#?

488