开发者

How can I reset a sequence's value to 1 for every new year in C#

I'm us开发者_运维百科ing the sequence to generate an identifier in the format YYYY-"sequence value" and the sequence value has to be reset to 1 for every new year. for example: for this year's value will be like 2011-3456. when new year comes, it should be set to like: 2012-0001. Thanks in advance!


Possible solution, assuming you want an identifier for each year and its yearly day:

private string GetYearlyIdentifier(DateTime date)
{
  return String.Format("{0:0000}-{0:000}",date.Year, date.DayOfYear);
}

(Not Tested)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜