Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Remove Leading Zeros from a String in C#
Let’s say the following is our string with leading zeros.
String str ="000234";
Use the TrimStart() method and set the 0 to remove it.
TrimStart(new Char[] { '0' } )
The following is the complete code to remove leading zeros.
Example
using System;
class Program {
static void Main() {
String str ="000234".TrimStart(new Char[] { '0' } );
Console.WriteLine(str);
}
}
Output
234
Advertisements
