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 is the difference between serialization and deserialization in c#?
What are classes in c#?
How do I create a multilanguage, single-file assembly?
Why do we use interfaces in c#?
What does return do in for loop?
We cannot create instances of static classes. Can we have constructors for static classes?
What is parallel foreach c#?
Explain the functionalities of satellite assembly?
Explain the constructor in c#.
What is default value of decimal c#?
How many digits are in an integer?
What is parse method in c#?
What are the different types of classes?
Why we use get and set method in c#?
What is nullable types in c#?