カスタム クラスがあり、そのプロパティの 1 つに値を暗黙的に割り当てたいと考えています。Microsoft がTextBox1 = "Sets the TextBox1.Text property"
. それはコンパイラに組み込まれているため、Microsoft にロックダウンされていますか、それとも利用可能ですか?
これは暗黙の変換に似ていますが、変更するには結果のインスタンスが必要です。
私の実際のコード例:
public class CustomObject<TObject>
{
public TObject BaseObject { get; set; }
//Psuedocode for what I want, this doesn't compile for multiple reason
public implicit operator CustomObject<TObject>(TObject FillIn)
{
this.BaseObject = FillIn;
}
}
//Usage
var x = new CustomObject<int>();
x = 3; //this is the end result I want to code.