
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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
- Related Articles
- Remove Leading Zeros From String in Java
- Remove leading zeros from a Number given as a string using Python
- How to remove leading zeros from a number in JavaScript?
- Remove Leading Zeros from an Array using C++
- Remove leading zeros in a JavaScript array?
- Remove leading zeros in array - JavaScript
- Remove leading zeros in array in JavaScript
- Java Program to Remove leading zeros
- Golang program to remove leading zeros
- Python program to remove leading zeros from an IP address
- Removing leading zeros from a String using apache commons library in Java
- Remove Trailing Zeros from string in C++
- Add leading Zeros to Python string
- Remove Leading Zeroes from a String in Java using regular expressions
- Explain how to remove Leading Zeroes from a String in Java

Advertisements