手机
当前位置:查字典教程网 >编程开发 >C#教程 >C# 判断字符串第一位是否为数字
C# 判断字符串第一位是否为数字
摘要:复制代码代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Compo...

复制代码 代码如下:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Text.RegularExpressions;

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Regex regChina = new Regex( "^[^x00-xFF]");

Regex regNum = new Regex( "^[0-9]");

Regex regChar = new Regex( "^[a-z]");

Regex regDChar = new Regex( "^[A-Z]");

string str = "YL闫磊";

if (regNum.IsMatch(str))

{

MessageBox.Show( "是数字");

}

else if (regChina.IsMatch(str))

{

MessageBox.Show( "是中文");

}

else if (regChar.IsMatch(str))

{

MessageBox.Show( "小写");

}

else if (regDChar.IsMatch(str))

{

MessageBox.Show( "大写");

}

}

}

}

【C# 判断字符串第一位是否为数字】相关文章:

c# 空合并运算符“??”的使用详解

C# dynamic关键字的使用方法

C# 一个WCF简单实例

c#中分割字符串的几种方法

C#几种截取字符串的方法小结

深入C#字符串和享元(Flyweight)模式的使用分析

C# 去除首尾字符或字符串的方法

c# 正则指引--字符组

C# 向二进制文件进行读写的操作方法

C#三种判断数据库中取出的字段值是否为空(NULL) 的方法

精品推荐
分类导航