return 作用域
今天在作题目的是的时候突然想到这个问题
class TimePeriod
{
private double seconds;
public virtual double Hours
{
get { return seconds / 3600; }
set { seconds = value * 3600;}
}
}
class TimePer : TimePeriod
{
}
class Program1
{
static void Main()
{
TimePeriod t = new TimePeriod();
// Assigning the Hours property causes the 'set' accessor to be called.
t.Hours = 24;
// Evaluating the Hours property causes the 'get' accessor to be called.
System.Console.WriteLine("Time in hours: " + t.Hours);
}
}
c#是一种块结构代码
return也只是在一个块里面有作用哦!!!!!!!!!!!