易截截图软件、单文件、免安装、纯绿色、仅160KB

使用C#正则表达式匹配相关字符串

C#正则表达式匹配字符串的方法如下:
1.使用C#中使用正则表达式System.Text.RegularExpressions命名空间;
2.使用C#中使用正则表达式Matches()方法匹配字符串,格式如下:
MatchCollection Matches = Regex.Matches(Str, Pattern, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);
其中Str表示输入字符串,Pattern表示匹配模式,RegexOptions.IgnoreCase表示忽略大小写,RegexOptions.ExplicitCapture表示改变收集匹配方式。
3.匹配结果保存在MatchCollection集合中,可以通过循环遍历结果集取出Match对象的结果。
TestRagular.cs:
using System;  
using System.Text.RegularExpressions;  
 
namespace Magci.Test.Strings  
{  
    public class TestRegular  
    {  
        public static void WriteMatches(string str, MatchCollection matches)  
        {  
            Console.WriteLine("\nString is : " + str);  
            Console.WriteLine("No. of matches : " + matches.Count);  
            foreach (Match nextMatch in matches)  
            {  
                //取出匹配字符串和最多10个外围字符  
                int Index = nextMatch.Index;  
                string result = nextMatch.ToString();  
    &


相关文档:

C#扫描计算机端口

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace PortScanner
{
class Program
{
 //已扫描端口数目
 internal static int scannedCount = 0;
 //正在运行的线程数目
 internal static int ru ......

C#清除页面缓存

C#清除页面缓存
    private void SetPageNoCache()
        {
            Response.Buffer = true;
            Response.ExpiresAbsolute = Sy ......

c# 类库

[SerializableAttribute]
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
public class Object
1 public virtual bool Equels (Object)
2 public static bool static Equels (Object,Object)
默认实现为对引用类型使用引用相等,对值类型使用二进制按位相等。引用相等性是指进 ......

C# 关键字extern用法

修饰符用于声明在外部实现的方法。extern 修饰符的常见用法是在使用 Interop 服务调入非
托管代码时与 DllImport 属性一起使用;在这种情况下,该方法还必须声明为 static,如下面的示例所示:[DllImport("avifil32.dll")]
private static extern void AVIFileInit();
注意
extern 关键字还可以定义外部程序集别名,使 ......

C#画线控件的开发应用实例解析

C#画线控件的应用实例介绍之前我们要明白在C#中没有画线的控件,这里写了一个,大家分享。共有两个控件分别是画横线和画竖线的,关于怎么画斜线有兴趣的可以做一个大家分享。
    C#画线控件之横线
using System;  
using System.Collections;  
using System.ComponentModel; ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号