Advertisement
Guest User

TransformUpper.cs

a guest
Feb 1st, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Text;
  4.  
  5. class TransformUpper
  6. {
  7.     static void Main()
  8.     {
  9.         string text = "We are living in a <upcase>yellow submarine</upcase>. We don't have <upcase>anything</upcase> else.";
  10.         char[] textArray = text.ToCharArray();
  11.         int index = 0;
  12.  
  13.         while ((index = text.IndexOf("<upcase>", index)) != -1)
  14.         {
  15.             index += 8;
  16.  
  17.             while (textArray[index] != '<')
  18.             {
  19.                 textArray[index] = Char.ToUpper(textArray[index]);
  20.                 index++;
  21.             }
  22.         }
  23.  
  24.         text = new string(textArray);
  25.         text = text.Replace("<upcase>", "").Replace("</upcase>", "");
  26.  
  27.         Console.WriteLine(text);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement