[Mono-list] Constructors in C#
Brice Carpentier
brice@daknet.org
Fri, 19 Nov 2004 23:41:06 +0100
Robert Shade wrote:
> How about a static method that returns a new instance?
>
> public class MyClass
> {
> private string login;
> private int uid;
> private string home;
>
> public MyClass (string login, int uid, string home)
> {
> // affect things
> }
>
> public static MyClass FromLine(string line)
> {
> System.text.RegularExpression.Regex.Split(line, ":");
> /* make some checks
> * (second field is an int, and so on ...) */
> // call next constructor
>
> return new MyClass(login, uid, home);
> }
> }
>
> rob
seems quite weird to me for something even vb is doing almost perfectly !
--
Brice Carpentier aka Br|ce