手机
当前位置:查字典教程网 >编程开发 >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# 获取网页中指定的字符串信息的实例代码

c#中判断字符串是不是数字或字母的方法

C# 一个WCF简单实例

c#判断输入的是不是数字的小例子

C#中字符串编码处理

C#使用非托管代码直接修改字符串的方法

C# 判断字符串为空的几种办法

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

C#注释的一些使用方法浅谈

精品推荐
分类导航