首页 > Windows开发 > 详细

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

时间:2020-07-05 10:51:38      阅读:98      评论:0      收藏: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);
         }
     }
 }

 

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

原文:https://www.cnblogs.com/netlock/p/13238084.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!