說我有實現它是否需要實例化一個類以供您閱讀其屬性之一?
public class concrete1 : IType{
public string property1 {get {return "testing1";}}
}
public class concrete2 : IType{
public string property1 {get {return "testing2";}}
}
我可以找出是哪個類包含字符串「testing2」沒有實例或者類的接口
public interface IType{
string property1 {get;}
}
和兩個班?這樣我才能實例化只有特定的一個。
我沒有蘋果。蘋果是紅色的嗎?也許,如果它是一個靜態蘋果。 – Magus
大聲笑,這就是我的想法,但很好奇,如果有人知道任何魔術 – erotavlas
這聽起來像有可能是一種更簡單的方法來實現您的最終目標。這可能是重新審視你的設計的時候了。你真的想要解決什麼問題?我的大腦現在正尖叫着「工廠模式」,但您並沒有真正提供足夠的信息來確定。 – itsme86