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 are the collections in c#?

660


What does || mean in programming?

663


What is an example of a delegate?

693


What is expression c#?

689


Explain the advantage of using system.text.stringbuilder over system.string?

656


What is foreach loop in c#?

714


Describe ways of cleaning up objects in c#.

678


How do partial classes work in c#?

682


What is the difference between protected and private?

685


Can you use foreach iteration on arrays in c#?

779


What is int64 in c#?

669


How does c# generics and c++ templates compare?

656


What are the problem with .NET generics?

730


What is interface c#?

634


what is IDisposal interface

909