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 does int32 mean?
What is the difference between readkey and readline in c#?
What is tryparse?
What Is The Smallest Unit Of Execution In .net?
What issues can be faced while delivering code?
What do you mean by for each loop?
Why to use “finally” block in c#?
What do u mean by thread safe?
What is an object and a class?
What is an xsd file?
What is xml serialization and deserialization in c#?
Describe the ways of cleaning up objects in c#.
What is the real use of interface in c#?
What is lock in c#?
What is the difference between values and reference types?