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 AllNumeric_CS { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(AllNumeric("123456").ToString()); MessageBox.Show(AllNumeric("12345A").ToString()); } private static bool AllNumeric(string inputString) { return Regex.IsMatch(inputString, @"^\d+$"); } } } |
檢查字串是否僅包含數值
最新推荐文章于 2021-10-17 11:25:15 发布