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 are immutable types in c#?
What is difference between dll and exe in c#?
What are the types of constructors?
Whats an assembly? Describe the importance of assembly?
windows c# using datagridview in edit form sql server
What is the use of parse in c#?
Is an interface a type c#?
Where are value types stored in c#?
Can delegates be used as callbacks?
Why do we need abstraction in c#?
Can a static class contain non static members?
What is the use of iqueryable in c#?
Explain the use of Mutex in C#?
What is the adv of using System.Text.StringBuilder over System.String?
In C#, explain the difference between overloading and overriding.