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
How do you declare a variable in c#?
Describe the parts of assembly.
How to implement delegates in c#.net
What are the types of constructors?
Is c# scripting language?
What is Fragmentation and its Types?
How to implement singleton design pattern in c#?
List some of the classes used by system.data namespace?
Are string objects mutable or immutable?
Is typeof c#?
Is stringbuilder better than string?
Is c# a keyword?
What is strong data type in c#?
What is an assembly in dotnet?
Is dll a library?