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
What is polymorphism c# example?
How can it prevents DLL Hell assembly versioning in .NET?
How to do and Apply Themes to Datagrid,Lable,Textbox,etc., in C#.NET 2005 Windows Application? (like who we will do themes in ASP.NET using .CSS and .SKIN files). Urgent!!
What is difference between dictionary and list in c#?
Is c# an open source language?
What is the difference between a field and a property in c#?
In which order the destructor is called for an inherited class?
What's the difference between a method and a procedure?
Can we instantiate abstract class in c#?
If you want to convert a base type to a derived type, what type of conversion do you use?
What do you mean by generic class in c#?
To create a localized application which namespaces are necessary?
Define parsing?
hi my question is about understanding a text the user entered to a site , so i want to analyse that text looking for some specific items such as "honda" "shoffere" etc.. so if this site could help or could tell me where to go with such question ,i wonder. thanks
What is orm in c#?