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 the collections in c#?
What does || mean in programming?
What is an example of a delegate?
What is expression c#?
Explain the advantage of using system.text.stringbuilder over system.string?
What is foreach loop in c#?
Describe ways of cleaning up objects in c#.
How do partial classes work in c#?
What is the difference between protected and private?
Can you use foreach iteration on arrays in c#?
What is int64 in c#?
How does c# generics and c++ templates compare?
What are the problem with .NET generics?
What is interface c#?
what is IDisposal interface