replace leading spaces with one space in c# code example
Example 1: add leading zeroes in c#
i.ToString().PadLeft(4, '0') - okay, but doesn't work for negative numbers
i.ToString("0000"); - explicit form
i.ToString("D4"); - short form format specifier
$"{i:0000}"; - string interpolation (C# 6.0+)
Example 2: C# regex replace all spaces with blank
LastName = Regex.Replace(LastName, @"\s+", "");