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


Please Help Members By Posting Answers For Below Questions

Which of the following API is used to hide a window?

751


What is the difference between function and method in c#?

647


Are c# objects passed by reference?

640


How can i Spawn a Thread

681


What is callback in c#?

647


Difference between abstract classes and interfaces

728


Why static variables are used?

704


What is the difference between dynamic type variables and object type variables in c#?

680


Illustrate the differences between the system.array.copyto() and system.array.clone()?

698


Which is more efficient for loop or while loop?

634


What is oledbconnection c#?

680


In which way a two-dimensional array declared in C#?

681


What is 8 bit signed integer?

643


How does foreach loop work in c#?

676


What is difference between private, protected, and public in C#?

762