[Mono-list] Constructors in C#

Bernd Waibel waebbl@gmx.de
Fri, 19 Nov 2004 22:16:42 +0100


On Fri, 19 Nov 2004 19:15:32 +0100
Brice Carpentier <brice@daknet.org> wrote:

Hello,

if I'm right, you want to intialize a member variable
with some default value. Why don't you initialize it
directly at declaration time? You should be able to use

public class MyClass
{
	private String member = "stuff";

	public MyClass() { }

	...
}


hth bernd


> Hi folks,
> I think I'm gonna ask a dumb question, but well, I've been crawling the 
> web for about an hour or so and didn't find the answer, so let's ask :
> 
> Basically what I want is what can be done in Java the following way :
> 
> public class MyClass
> {
> 	private String member;
> 
> 	public MyClass ()
> 	{
> 		this("stuff");
> 	}
> 
> 	public MyClass (String s)
> 	{
> 		this.member = s;
> 	}
> }
>