每天知道多一点

To learn more everyday!
1:RegularExpressions

正则表达式

 正则表达式存在于命名空间System.Text.RegularExpressions中.这个类的方法常用的是IsMatch,表示某个字符串中是否包含某个指定的字符串.还有类似的Matche和Matches就比较麻烦,暂时不晓得什么地方可以用.以后再了解.

 1using System;
 2 using System.Text.RegularExpressions;
 3class test
 4{
 5    static void Main()
 6    {
 7        string str="xxxyyc";
 8        Regex rg=new Regex("yyc");
 9        if(rg.IsMatch(str)==true)
10        {
11            Console.WriteLine("true");
12        }

13    }

14}

 


2:Fibonacci数列
1+1+2+3+5+8+......使用递归算法计算第N个数的值
 1using System;
 2 class demo
 3 {
 4     public static int fibo(int i)
 5     {
 6         if(i<3)
 7             return 1;
 8         if(i<0)
 9             return 0;
10         else
11             return fibo(i-2)+fibo(i-1);
12     }

13     static void Main()
14     {
15         Console.WriteLine(fibo(30));
16     }

17 }

18
19
posted @ 2008-04-17 17:09  L.Net  阅读(176)  评论(0编辑  收藏  举报