当前位置:编程学习 > C#/ASP.NET >>

如何查看字符串特定位置是否为特定字符

比如看字符串第一个字符是否为0最后一个字符是否为. --------------------编程问答--------------------
if(String.Index(位置)=="") then
--------------------编程问答-------------------- if("0123".StartWith("0"))
{
} --------------------编程问答-------------------- 好像没有.Index啊 --------------------编程问答-------------------- 特定位置,不一定是首字符 --------------------编程问答-------------------- string s="ab0123";
if(s[0]=='0')
{
} --------------------编程问答-------------------- if("0123".StartsWith("0"))
{
} --------------------编程问答-------------------- string a = "0123456."

if (a.StartsWith("0"))  //如果字符串第一个字符是为0
{

}
if (a. a.EndsWith(".")) //如果字符串最后一个字符是为.
{

} --------------------编程问答-------------------- 上面笔误。。多写了个 a.

正确如下:
string a = "0123456."

if (a.StartsWith("0")) //如果字符串第一个字符是为0
{

}
if (a.EndsWith(".")) //如果字符串最后一个字符是为.
{

} --------------------编程问答-------------------- 特定位置的,比如第四个字符是否为a --------------------编程问答-------------------- string a = "054132587."

if (a.StartsWith("0")) 如果为首字符0,则为真
{

}
if (a.EndsWith(".")) //如果为尾字符.则为真
{

} --------------------编程问答--------------------

         string str = "123123213";
         str.StartsWith("");//第一个
          str.EndsWith("");//最后一个
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,