本文整理汇总了C#中Time.AddDays方法的典型用法代码示例。如果您正苦于以下问题:C# Time.AddDays方法的具体用法?C# Time.AddDays怎么用?C# Time.AddDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time.AddDays方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSampleFile
static void CreateSampleFile(string filename, int n)
{
r = new Random(1);
var t = new Time(2000, 1, 1);
File.Delete(filename);
using (var tf = TeaFile<Tick>.Create(filename))
{
while (n-- > 0)
{
bool isGoodDay = DrawRandom(90);
WriteDailyTicks(tf, t, isGoodDay);
t = t.AddDays(1);
}
}
}
示例2: IOException
public void IOException()
{
var stream = new TestStream();
using (var tf = TeaFile<Event<int>>.Create(stream))
{
Time t = new Time(2000, 1, 1);
tf.Write(Enumerable.Range(1, 5).Select(i => new Event<int> {Time = t.AddDays(i), Value = i}));
}
stream.Position = 0;
stream.FailAfterPosition = stream.Length - 2;
using (var tf = TeaFile<Event<int>>.OpenRead(stream))
{
tf.Count.Should().Be(5); // the count is still 5, the stream length has not changed
tf.Read().Value.Should().Be(1);
tf.Read().Value.Should().Be(2);
tf.Read().Value.Should().Be(3);
tf.Read().Value.Should().Be(4);
Executing.This(() => tf.Read()).Should().Throw<IOException>();
}
}
示例3: AddDays
public void AddDays()
{
Time.Scale = Timescale.Net;
Time t = new Time(2010, 2, 3);
Time t2 = t.AddDays(5);
(t2.NetTime - t.NetTime).TotalDays.Should().Be(5);
Time.Scale = Timescale.Java;
t = new Time(2010, 2, 3);
t2 = t.AddDays(5);
(t2.NetTime - t.NetTime).TotalDays.Should().Be(5);
}