Answer the question
In order to leave comments, you need to log in
How to convert such a constructor in C#?
1 photo - what I originally had
2 photos - teacher's remark (what needs to be redone)
3 photo - how I redid this
4 photos - and these are the errors it gives (Impossible to assign a value to a property ...)
How to do it normally and why errors???
Answer the question
In order to leave comments, you need to log in
ptivate int _num;
private int _den;
Drob(int num, int den)
{
_num = num;
_den = den;
}
public int Num
{
get
{
return _num;
}
}
public int Den
{
get
{
return _den;
}
}
public override strin ToString()
{
...
_num = -_num;
_den = Math.Abs(_den);
...
}
public int Num
{
get => _num; // а это новая форма записи, короче и красивей той что у вас
set =>_num = value; // Присвоение значения собственно почему у вас и ругается, нет этого метода
}
public int NumSecond
{
get => _sec; // а это новая форма записи, короче и красивей той что у вас
private set =>_sec = value; // А тут закрываете доступ извне
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question