本文整理汇总了C#中Time.AddHours方法的典型用法代码示例。如果您正苦于以下问题:C# Time.AddHours方法的具体用法?C# Time.AddHours怎么用?C# Time.AddHours使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time.AddHours方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_Add_Hours
public void Can_Add_Hours()
{
Time time = new Time(12,30);
time = time.AddHours(1);
Assert.AreEqual(13,time.Hour);
Assert.AreEqual(30,time.Minute);
time = time.AddHours(11);
Assert.AreEqual(0,time.Hour);
}
示例2: WriteDailyTicks
static void WriteDailyTicks(TeaFile<Tick> tf, Time day, bool isGoodDay)
{
Time t = day.AddHours(9); // start trading session at 09:00
Time end = day.AddHours(17.5); // end trading session at 17:30
while (t < end)
{
// on a good day, we write many ticks, on a bad day however only 1 percent as much
if (isGoodDay || DrawRandom(1))
{
double p = r.NextDouble() * 100000.0;
tf.Write(new Tick {Time = t, Price = p, Volume = 10});
}
t = t.AddSeconds(15 + r.Next(0, 20));
}
}
示例3: AddHourMoreThan_23_hour
public void AddHourMoreThan_23_hour()
{
int hour = 1;
int mins = 0;
int second = 0;
var target = new Time(hour, mins, second);
int hour1 = 29;
target = target.AddHours(hour1);
Assert.AreEqual("6:0:0", target.ToString());
}
示例4: AddHourTest
public void AddHourTest()
{
int hour = 1;
int mins = 2;
int second = 3;
var target = new Time(hour, mins, second);
int hour1 = 3;
target.AddHours(hour1);
var expect = new DateTime(1, 1, 1, hour, mins, second);
expect.AddHours(hour1);
Assert.AreEqual(expect.Ticks, target.Ticks);
}