Created
October 21, 2015 10:43
-
-
Save demofan/ba735f6d7069de2089a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static string GetNoLastNumber(int? random = null) | |
{ | |
var dictionary = new[] { "a", "b", "c", "d", "e", "f", "g", "h", "k", "m", "p", "r" }; | |
if (random.HasValue==false) | |
{ | |
random = new Random().Next(0, 9); | |
} | |
return dictionary[random.Value]; | |
} | |
/// <summary> | |
/// 產出活動序號 | |
/// </summary> | |
/// <param name="eventDate">The event date.</param> | |
/// <returns>System.String.</returns> | |
public static string GenerateNo(DateTime eventDate) | |
{ | |
var day1 = (eventDate.Day / 10); | |
var day2 = (eventDate.Day % 10); | |
return | |
$"{GetNoLastNumber(eventDate.Month - 1)}{GetNoLastNumber(day1)}{GetNoLastNumber(day2)}{GetNoLastNumber()}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot. Also,