手机
当前位置:查字典教程网 >编程开发 >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# 一个WCF简单实例

C# dynamic关键字的使用方法

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

C# 将字节流转换为图片的实例方法

获取字符串中的汉字拼音首字母

C#利用子线程刷新主线程分享教程

C#枚举中的位运算权限分配浅谈

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

c# 获取网页中指定的字符串信息的实例代码

C#.NET字符串比较中忽略符号的方法

精品推荐
分类导航