Author : MD TAREQ HASSAN | Updated : 2020/08/02

Unique Id Generation

Using DateTime to generate unique id

using System;
using System.Numerics;


public class UniqueIdProvider
{
	public static BigInteger GetIntId()
	{
		var str = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");

		var uniqueId = BigInteger.Parse(str);

		return uniqueId;
	}
}

Initials of FullName

Courtesy: https://stackoverflow.com/a/53990056/4802664 (<= StackoverFlow Question: regex-to-extract-initials-from-name)

using System.Text.RegularExpressions;

public class TextUtil
{
	private const string PatternForInitialLetterExtraction = @"(?i)(?:^|\s|-)+([^\s-])[^\s-]*(?:(?:\s+)(?:the\s+)?(?:jr|sr|II|2nd|III|3rd|IV|4th)\.?$)?";
	public static string GetInitials(string fullName) => Regex.Replace(fullName, PatternForInitialLetterExtraction, "$1").ToUpper();
}