public class Currency{
private Code {get;set;}
public Currency(string code){
this.Code = code;
}
//more methods here
}
我希望能夠讓我的對象澆注料是否可以將字符串轉換爲我自己的類型?
string curr = "USD";
Currency myType = (Currency)curr;
我知道,我可以用構造器做到這一點,但我已經用例,我需要投不初始化對象...
我也認爲生病需要像FromString()
這樣的功能來做
謝謝。
看吧http://msdn.microsoft.com/en-us/library/xhbhezf4(v=vs .71).aspx –