C# 如何查询字符串前面有几个0

有几个0
string t = "0001203";
int tLen = t.Length - t.TrimStart('0').Length;
charAt方法
using System;
 
 namespace Company{
 
     public class TestMain{
         static void Main(){
             string str = "abcdefg";
             string n_str = str.CharAt(3);
             Console.WriteLine(n_str);
         }
     }
     
     public static class CharAtExtention{
         public static string CharAt(this string s,int index){
             if((index >= s.Length)||(index<0))
                 return "";
             return s.Substring(index,1);
         }
     }
 }
原文地址:https://www.cnblogs.com/netlock/p/13238084.html