When you inherit a protected class-level variable, who is it
available to?
Answers were Sorted based on User's Feedback
//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 |
Why c# is type safe?
What are the principles of delegation?
How many types of collections are there in c#?
Why we put script in head of asp.net page Why not in body?
How does inheritance work in c#?
write a c# program add two matrix with input number ?
What is a long in c#?
How do you declare an arraylist?
What is primitive types in c#?
Are classes passed by reference in c#?
Why do we use anonymous method in c#?
What is Implementation inheritance