How to remove 2 Zeros in the beginning of a string

Kannan1212

New member
Joined
Apr 11, 2020
Messages
4
Programming Experience
1-3
This is my code -
var creditAccount = response.Accounts.Where(x => x.Value.Identifier.ProductCode == "MMM").Select(x=>x.Value.Identifier).ToList();
// For Example :- creditAccount - 0000002134665300468820,0000001528830814061271
foreach (var item in creditAccount)
{
permanentIdList.Add(item.PermanentIdentifier);
}

Here i Need to remove two zeros in the creditAccount before pushing into the list. Please help me How do I remove that.
I am expecting - For Example :- creditAccount - 00002134665300468820, 00001528830814061271
 
Have you even tried using Substring()?
 
Firstly welcome to the forum.

Secondly, just call Remove :
C#:
string newCardNumber = "0000002134665300468820,0000001528830814061271".Remove(0, 2);

This gives you : 00002134665300468820,0000001528830814061271 as thus :
C#:
string newCardNumber = "0000002134665300468820,0000001528830814061271".Substring(2, "0000002134665300468820,0000001528830814061271".Length - 2);
Lastly, please try searching the forum or using a search engine before asking to do something which has been asked a million times already. Asking for help on any forum should be your last resort. Not trying to discourage questioning, but if you searched around, you would have had no problem finding a solution to something as simple.
 
+1

Or our OP could take time to read the documentation. There is even an explicit section regarding this:
 
Back
Top Bottom