国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > 綜合 > 正文

幾個(gè)C# PROGRAMS (2)

2024-07-21 02:17:51
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
 

using system;
using system.text.regularexpressions;

namespace wrox.procsharp.regularexpressionplayaround
{
   class mainentrypoint
   {
      static void main()
      {
         find1();
         console.readline();
      }

      static void find1()
      {
         string text = @"xml has made a major impact in almost every aspect of
            software development. designed as an open, extensible, self-describing
            language, it has become the standard for data and document delivery on
            the web. the panoply of xml-related technologies continues to develop
            at breakneck speed, to enable validation, navigation, transformation,
            linking, querying, description, and messaging of data.";
         string pattern = @"/bn/s*ion/b";
         matchcollection matches = regex.matches(text, pattern,
            regexoptions.ignorecase | regexoptions.ignorepatternwhitespace |
            regexoptions.explicitcapture);
         writematches(text, matches);
      }  

      static void find2()
      {
         string text = @"xml has made a major impact in almost every aspect of
            software development. designed as an open, extensible, self-describing
            language, it has become the standard for data and document delivery on
            the web. the panoply of xml-related technologies continues to develop
            at breakneck speed, to enable validation, navigation, transformation,
            linking, querying, description, and messaging of data.";
         string pattern = @"/bn";
         matchcollection matches = regex.matches(text, pattern,
           regexoptions.ignorecase);
         writematches(text, matches);
      }

      static void writematches(string text, matchcollection matches)
      {
         console.writeline("original text was: /n/n" + text + "/n");
         console.writeline("no. of matches: " + matches.count);
         foreach (match nextmatch in matches)
         {
            int index = nextmatch.index;
            string result = nextmatch.tostring();
            int charsbefore = (index < 5) ? index : 5;
            int fromend = text.length - index - result.length;
            int charsafter = (fromend < 5) ? fromend : 5;
            int charstodisplay = charsbefore + charsafter + result.length;

            console.writeline("index: {0}, /tstring: {1}, /t{2}",
               index, result,
               text.substring(index - charsbefore, charstodisplay));

         }
      }
   }
}

using system;
using system.text;

namespace wrox.procsharp.stringencoder
{
   class mainentrypoint
   {
      static void main(string[] args)
      {
         string greetingtext = "hello from all the guys at wrox press. ";
         greetingtext += "we do hope you enjoy this book as much as we enjoyed writing it.";

         for(int i = (int)'z'; i>=(int)'a' ; i--)
         {
            char old = (char)i;
            char new = (char)(i+1);
            greetingtext = greetingtext.replace(old, new);
         }

         for(int i = (int)'z'; i>=(int)'a' ; i--)
         {
            char old = (char)i;
            char new = (char)(i+1);
            greetingtext = greetingtext.replace(old, new);
         }
         console.writeline("encoded:/n" + greetingtext);

         stringbuilder greetingbuilder =
            new stringbuilder("hello from all the guys at wrox press. ", 150);
         greetingbuilder.append("we do hope you enjoy this book as much as we enjoyed writing it");

         for(int i = (int)'z'; i>=(int)'a' ; i--)
         {
            char old = (char)i;
            char new = (char)(i+1);
            greetingbuilder = greetingbuilder.replace(old, new);
         }

         for(int i = (int)'z'; i>=(int)'a' ; i--)
         {
            char old = (char)i;
            char new = (char)(i+1);
            greetingbuilder = greetingbuilder.replace(old, new);
         }
         console.writeline("encoded:/n" + greetingbuilder.tostring());
     
      }
   }
}

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 朝阳市| 遂平县| 海门市| 前郭尔| 策勒县| 宁津县| 黄浦区| 南郑县| 满城县| 德兴市| 简阳市| 南开区| 大埔区| 阳城县| 清河县| 靖州| 资阳市| 奉新县| 扬中市| 翼城县| 西宁市| 钟祥市| 高碑店市| 南岸区| 万安县| 吉木乃县| 当雄县| 菏泽市| 清新县| 长武县| 永济市| 确山县| 泾源县| 开化县| 花垣县| 阳朔县| 永年县| 南岸区| 延边| 承德县| 茶陵县|