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 / tsahi
that depends on weather you are writing a class or a struct.
in a class, the first answer given is correct (i.e. two
constructors). in a struct, you cannot write a default
constructor, and you will always have the automatically
generated one, in addition to any other constructor you may
write by your self.
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Explain the use of Mutex in C#?
What can I create with c#?
What is the purpose of namespace?
Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?
Can property be private in c#?
Which compiler switch creates an xml file from xml comments in the files in an assembly?
What operators can be used to cast from one reference type to another without the risk of throwing an exception?
How to move to a state-related codebase?
How do you declare a variable in c#?
When a Static Constructor is called in a Class?
What is the advantage of constructor?
What is the purpose of the integer parse method the decimal parse method?
What is different between Boxing and Unboxing?
What are primitive types in c#?
What does string format do?