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 a constructor? What is a destructor?
What is data adapter in c#?
Can you pass value types by reference to a method?
Explain how to add controls dynamically to the form using c#.net.
How big is an int16?
What are the properties of string?
What is iqueryable in linq?
What is the difference between add and addrange in c#?
Explain the difference between the debug class and trace class?
What is enumerable in c#?
Is it good to use var in c#?
What is meant by unicode characters?
What is the data encapsulation?
Is there any sample c# code for simple threading?
Is concurrent queue thread safe?