joseh254

Phun With Strings CHL

Mar 17th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7.  
  8. namespace ChallengePhunWithStrings
  9. {
  10.     public partial class Default : System.Web.UI.Page
  11.     {
  12.         protected void Page_Load(object sender, EventArgs e)
  13.         {
  14.             // 1.  Reverse your name
  15.             string name = "Jose Hernandez";
  16.             // In my case, the result would be:
  17.             // robaT boB
  18.             for (int i = name.Length - 1; i >= 0; i--)
  19.             {
  20.                 resultLabel.Text += name[i];
  21.             }
  22.  
  23.  
  24.  
  25.             // 2.  Reverse this sequence:
  26.             string names = "Luke,Leia,Han,Chewbacca";
  27.             // When you're finished it should look like this:
  28.             // Chewbacca,Han,Leia,Luke
  29.             //List<string> names = "Luke,Leia,Han,Chewbacca".Split(',').ToList<string>();
  30.             //reverseLabel.Text = names.ToString();
  31.            
  32.             string[] reversedList = names.Split(',');
  33.             string rev = "";
  34.             for (int i = reversedList.Length - 1; i >= 0; i--)
  35.             {
  36.                 rev += reversedList[i] + ",";
  37.             }
  38.             rev = rev.Remove(rev.Length - 1, 1);
  39.             reverseLabel.Text = rev;
  40.  
  41.  
  42.  
  43.             string stWars = "Luke,Leia,Han,Chewbacca";
  44.             // 3. Use the sequence to create ascii art:
  45.             // *****luke*****
  46.             // *****leia*****
  47.             // *****han******
  48.             // **Chewbacca***and
  49.  
  50.             //asciiLabel.Text="luke".PadLeft(5,'*') + "".PadRight(5, '*') ;
  51.             string[] starsCh = stWars.Split(',');
  52.             string res = "";
  53.             for (int i = 0; i < res.Length; i++)
  54.             {
  55.                 res += res[i] + "" res[i].
  56.             }
  57.             asciiLabel.Text = starsCh.ToString();
  58.  
  59.  
  60.            
  61.  
  62.  
  63.             // 4. Solve this puzzle:
  64.  
  65.             string puzzle = "NOW IS ZHEremove-me ZIME FOR ALL GOOD MEN ZO COME ZO ZHE AID OF ZHEIR COUNZRY.";
  66.  
  67.             // Once you fix it with string helper methods, it should read:
  68.             // Now is the time for all good men to come to the aid of their country.
  69.  
  70.  
  71.  
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment