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
How do I format in c#?
What is difference between list and ilist in c#?
What is the purpose of abstract class in c#?
What is a protected class c#?
What .exe means?
Can int be null c#?
What is asax file in c#?
What is an example of delegation?
How do I open the console window?
Explain the different types of delegates used in c#.
What is a .exe extension files? How is it similar to .dll extension files?
What are the differences between a class and a struct?
What are the characteristics of c#?
Differentiate between method overriding from method overloading with its functionality?
Can you inherit multiple abstract classes in c#?