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
Does console.writeline() stop printing when it reaches a null character within a string?
Int map to which .net types?
Can we set image Source dynamically using C# in WPF application?
What is hierarchical inheritance in c#?
Major difference between Basic httpbinding and WShttpbinding?
Explain “static” keyword in c#?
Why do we use 0?
When do we generally use destructors to release resources?
What is the difference between dll and lib?
Is array passed by reference in c#?
what is the syntax to inherit from a class in c#?
Define satellite assembly in c#?
What's difference between constants and static readonly?
What is difference between arraylist and list in c#?
Hi Friends, I am going through Siemens Interview Procedure from last 1+1/2 months. I went through 1 written + 2 Technical + 1 Managerial Round process after which I got call from HR informing that "you are selected and we would like to meet you for HR round". HR round was very nominal compared to MR. HR Round last for hardly 5 mins. They told me that you will get the final result on Friday. Still I have not received any feedback from them. Please help!!!