You can use PadLeft
var newString = Your_String.PadLeft(4, '0');
More Related Contents:
- What is the difference between String and string in C#?
- Why .NET String is immutable? [duplicate]
- Escape double quotes in a string
- What is the difference between String and string in C#?
- Why would you use String.Equals over ==? [duplicate]
- How do I write a backslash (\) in a string?
- Evaluate string with math operators [duplicate]
- Splitting a string / number every Nth Character / Number?
- Is String.Contains() faster than String.IndexOf()?
- What’s does the dollar sign ($”string”) do? [duplicate]
- Get host domain from URL?
- How the StringBuilder class is implemented? Does it internally create new string objects each time we append?
- Test if string is a guid without throwing exceptions?
- How is GetHashCode() of C# string implemented?
- How to include quotes in a string
- How do I interpolate strings?
- C# testing to see if a string is an integer?
- String sorting issue in C#
- Convert array of integers to comma-separated string
- Format a string into columns
- String to Binary in C#
- ComboBox.SelectedText doesn’t give me the SelectedText
- Top level domain from URL in C#
- How to do ToString for a possibly null object?
- String.Format – how it works and how to implement custom formatstrings
- .NET method to convert a string to sentence case
- Does String.GetHashCode consider the full string or only part of it?
- Fastest way to check if string contains only digits in C#
- Convert String^ in c# to CString in c++/CLI
- what’s the use of string.Clone()?