I have two constructors which feed values to readonly fields. 我有兩個構造函數,它們將值提供給只讀字段。 ide
public class Sample { public Sample(string theIntAsString) { int i = int.Parse(theIntAsString); _intField = i; } public Sample(int theInt) => _intField = theInt; public int IntProperty => _intField; private readonly int _intField; }
One constructor receives the values directly, and the other does some calculation and obtains the values, then sets the fields. 一個構造函數直接接收值,另外一個構造函數進行一些計算並得到值,而後設置字段。 函數
Now here's the catch: 如今這是要抓住的地方: this
Any ideas? 有任何想法嗎? idea