C# 正则表达式(2)
// pattan = @"[^ahou]"; 表示匹配除ahou之外的字符,^在表示反义
string res4 = Regex.Replace(s, @"[^ahou]", "*");
Console.WriteLine(res4);
res3 = Regex.IsMatch(s, @"^d{5,12}$"); //表示匹配是否是5-12位之间的数字// pattan = @"[^ahou]"; 表示匹配除ahou之外的字符,^在表示反义
string res4 = Regex.Replace(s, @"[^ahou]", "*");
Console.WriteLine(res4);
res3 = Regex.IsMatch(s, @"^d{5,12}$"); //表示匹配是否是5-12位之间的数字属性反映了状态,是对字段的自然扩展。下面的代码,有一个学生类,类中有年龄属性,通过get,set对年龄进行值的获取与设置,同时对年龄进行约束,使值控制在0-120之间,否则抛出异常信息。namespace _20200324_2 { cl...
事件的拥有者与事件的响应者是分开的情况+=是事件订阅操作符,左边是事件,右边是事件处理器。using System; using System.Windows.Forms; /// <summary> /// 事件的拥有者和事件的响应者是...
事件的拥有者同时是事件的响应者using System; using System.Windows.Forms; /// <summary> /// 事件的拥有者同时是事件的响应者 /// </summary> na...
简单用法,一句一句来,便于理解 Func<int, int, int> func = new Func<int, int, int>((int a, int b) => { return a * b; });(int a, int b) => { ret...
Directory类:静态类,主要处理文件目录。方法:CreateDirectory(String)在指定路径中创建所有目录和子目录,除非它们已经存在。返回值是一个DirectoryInfo对象Delete(String)从指定路径删除空目录。无返回值。Exists(String)确定给定路径是否引...