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


Please Help Members By Posting Answers For Below Questions

What does int32 mean?

477


What is the difference between readkey and readline in c#?

456


What is tryparse?

519


What Is The Smallest Unit Of Execution In .net?

526


What issues can be faced while delivering code?

1478






What do you mean by for each loop?

481


Why to use “finally” block in c#?

533


What do u mean by thread safe?

500


What is an object and a class?

557


What is an xsd file?

508


What is xml serialization and deserialization in c#?

484


Describe the ways of cleaning up objects in c#.

522


What is the real use of interface in c#?

466


What is lock in c#?

486


What is the difference between values and reference types?

526