Page 1 of 1

C# Constructors...

Posted: April 9th, 2006, 6:42 pm
by Rafael
Hi There...

Please, in C#, what I need to myself starts the constructor in my plugin?

for example...

I need start the constructor with a parameter..

public LCDSmartie(string cod)

and so... when you call the first function, I need to send one parameter, like this:

public string function1(string param1, string param2)
{
this(param1);
// code, bla, bla..
}

Can I do this? Can I myself start a Constructor?

Thanks!

Posted: April 9th, 2006, 6:53 pm
by erlis
Well then you will be creating a new object of your class.

So NO, that is not possible, create a seperate method for that.

Posted: April 9th, 2006, 7:20 pm
by Rafael
Sure, but I need to use a parameter sended by user in constructor!

I change the constructor by private void init(string cod).

But every time that the smartie calls this DLL, Will be used a new place in memory, isn?t?

What I have now...

public LCDSmartie() {}

public string function1(string param1, string param2)
{
init(param1);
}

private void init(string cod)
{
sr = new StreamReader(file, Encoding.GetEncoding(cod));
// code...
}

:oops: