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
What is windows application in c#?
Is overriding of a function possible in the same class?
What’s thread.sleep() in threading ?
What can be done with c#?
What are the collection types can be used in c#?
What are functions in c#?
What is a method c#?
What are properties in c#. Explain with an example?
Is learning c# hard?
What is the use of list in c#?
What is a template class?
What is unsigned int?
What is class method c#?
What is Event - Delegate?
What is the difference between function and method in c#?