C# provides a default constructor for me. I write a
constructor that takes a string as a parameter, but want to
keep the no parameter one. How many constructors should I write?
Answer Posted / kiran
namespace SameNamespace
{
class MyBaseClass
{
protected internal int myprotectedinternalint;
private string myName;
public MyBaseClass(string abc)
{
myName = abc;
}
public MyBaseClass()
{
}
}
class MyDerivedClass:MyBaseClass
{
public int GetProtectedInternalMember()
{
return myprotectedinternalint;
}
public MyDerivedClass(int myvalue)
{
myprotectedinternalint = myvalue;
}
}
class MyTest
{
public static void Main()
{
MyBaseClass mbc = new MyBaseClass();
MyDerivedClass mdc = new MyDerivedClass(12);
Console.WriteLine(mdc.GetProtectedInternalMember
());
Console.ReadKey();
}
}
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Which of the following API is used to hide a window?
What is the difference between function and method in c#?
Are c# objects passed by reference?
How can i Spawn a Thread
What is callback in c#?
Difference between abstract classes and interfaces
Why static variables are used?
What is the difference between dynamic type variables and object type variables in c#?
Illustrate the differences between the system.array.copyto() and system.array.clone()?
Which is more efficient for loop or while loop?
What is oledbconnection c#?
In which way a two-dimensional array declared in C#?
What is 8 bit signed integer?
How does foreach loop work in c#?
What is difference between private, protected, and public in C#?