我们先来看一些代码及其编译结果。
实例一: #include "stdafx.h" #include <iostream.h>
class CB { public: void f(int) { cout << "CB::f(int)" << endl; }
1.通过正则表达式(可以判断正数和负数) public int IsNumeric(string str) { int i; if(str != null && System.Text.RegularExpressions.Regex.IsMatch(str,@"^-?\d+$")) i = int.Parse(str); else i = -1; return i; } 2.通过字符 /// <summary> /// 判断是否是数字
private void Form1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //其中label1.Text显示的就是拖进文件的文件名;