Вот мой код: < /p>
Код: Выделить всё
public class BankAccountNew(string accountID, string owner)
{
public void DoSomethingWrong()
{
accountID = "Wrong";
}
}
public class BankAccounOld
{
private readonly string accountID;
private readonly string owner;
public BankAccounOld(string accountID, string owner)
{
this.accountID = accountID;
this.owner = owner;
}
public void DoSomethingWrong()
{
accountID = "Wrong";
}
}
, как предполагается, объясняется accountId . Как изменить BankAccountnew , чтобы убедиться, что это распознается как Readonly, чтобы он запустил ошибку компилятора?
Подробнее здесь: https://stackoverflow.com/questions/770 ... s-readonly
Мобильная версия