Add zero-padding to a string
You can use PadLeft
var newString = Your_String.PadLeft(4, '0');
myInt.ToString("D4");
string strvalue="11".PadRight(4, '0');
output= 1100
string strvalue="301".PadRight(4, '0');
output= 3010
string strvalue="11".PadLeft(4, '0');
output= 0011
string strvalue="301".PadLeft(4, '0');
output= 0301
"1".PadLeft(4, '0');