I am trying to create a class that can create itself using a static method but where you can still access the instance member after it creates itself. Why am I finding this so hard to do?
public class Widget
{
public static Widget Init()
{
return new Widget();
}
public string WidgetUPC {get; set;}
}
...when I create an instance like this...
var w = Widget.Init();
I cannot set the property like this...
w.WidgetUPC = 'someUPC';
The instance Why not?
What changes can I make to get this to work?
Aucun commentaire:
Enregistrer un commentaire