下面是一个使用正则表达式搜索字符串的一段代码:
  string[] zhous=
{
   "C# wo de zui ai",
   "C# si very good",
   "Beijing huan ying ni",
   "Zhong Guo 2009",
   };
   string zhous="^C
   foreach(string s in zhous)
   {
       Console.Write("{0,32}",); ————————————→(这个代表什么?)
   
    if(Regex.IsMatch(s,sPatten,RegexOptions.IgnoreCase))  ————————————→(这个代表什么?)
  {
        Console.WriteLine("  (mach for '{0}' found)",sPatten);
   }
    else
    {
         Conlose.WriteLine("  no mach here!");
     }
    }       
          Console.ReadLine();

解决方案 »

  1.   

    Console.Write("{0,32}",); 这个逗号后面貌似不全。这个{0,32}表示显示的格式。按照32字符对齐。if(Regex.IsMatch(s,sPatten,RegexOptions.IgnoreCase)) 如果匹配(字符串,模式,忽略大小写)
      

  2.   

    lz 的代码好多问题:        static void Main(string[] args)
            {
                string[] zhous = 

      "C# wo de zui ai", 
      "C# si very good", 
      "Beijing huan ying ni", 
      "Zhong Guo 2009", 
      };
                string sPatten = "^C";
                foreach (string s in zhous)
                {
                    Console.Write("{0,32}", s); //————————————→(这个代表什么?)                 if (Regex.IsMatch(s, sPatten, RegexOptions.IgnoreCase)) // ————————————→(这个代表什么?) 
                    {
                        Console.WriteLine("  (mach for '{0}' found)", sPatten);
                    }
                    else
                    {
                        Console.WriteLine("  no mach here!");
                    }
                }
                Console.ReadLine();        }
      

  3.   

    Console.Write("{0,32}",S);   正确的应该是这样的- -!
    刚开始学,失误了自己都不知道。。呵呵
    顺便问句LZ 是什么意思?