TimeSpan is a type, which is not valid in TimeSpan - C#
Формулировка задачи:
public void DisplayTime()
{
if (this.startTime.Year != 1)
{
this.interval = new TimeSpan();
DateTime startTime = new DateTime();
string str = "";
if (this.inPlayTime.Year == 1)
{
startTime = this.startTime;
}
else
{
startTime = this.inPlayTime;
}
if (this.inPlayGo)
{
this.lbTime.ForeColor = Color.DarkGreen;
this.interval = (TimeSpan) (DateTime.Now - startTime);
}
else
{
this.lbTime.ForeColor = Color.Black;
this.interval = (TimeSpan) -(DateTime.Now - this.startTime);
^^^^^^^^
тут ошибка
Severity Code Description Project File Line
Error CS0119 'TimeSpan' is a type, which is not valid in the given context botbeetle
if ((Convert.ToInt32(this.interval.TotalMinutes) == ClassSound.time) && this.bool_0)
{
this.bool_0 = false;
if ((ClassSound.spTimeStart != null) && ClassSetting.SoundOn)
{
try
{
ClassSound.spTimeStart.Play();
base.Show();
base.BringToFront();
}
catch
{
}
}
}
}
str = str + this.interval.ToString();
int index = str.IndexOf('.');
if (index < 0)
{
index = str.Length;
}
this.lbTime.Text = str.Substring(0, index);
}
}Решение задачи: «TimeSpan is a type, which is not valid in TimeSpan»
textual
Листинг программы
(TimeSpan) -(DateTime.Now - this.startTime)