Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace ChallengePhunWithStrings
- {
- public partial class Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- // 1. Reverse your name
- string name = "Jose Hernandez";
- // In my case, the result would be:
- // robaT boB
- for (int i = name.Length - 1; i >= 0; i--)
- {
- resultLabel.Text += name[i];
- }
- // 2. Reverse this sequence:
- string names = "Luke,Leia,Han,Chewbacca";
- // When you're finished it should look like this:
- // Chewbacca,Han,Leia,Luke
- //List<string> names = "Luke,Leia,Han,Chewbacca".Split(',').ToList<string>();
- //reverseLabel.Text = names.ToString();
- string[] reversedList = names.Split(',');
- string rev = "";
- for (int i = reversedList.Length - 1; i >= 0; i--)
- {
- rev += reversedList[i] + ",";
- }
- rev = rev.Remove(rev.Length - 1, 1);
- reverseLabel.Text = rev;
- string stWars = "Luke,Leia,Han,Chewbacca";
- // 3. Use the sequence to create ascii art:
- // *****luke*****
- // *****leia*****
- // *****han******
- // **Chewbacca***and
- //asciiLabel.Text="luke".PadLeft(5,'*') + "".PadRight(5, '*') ;
- string[] starsCh = stWars.Split(',');
- string res = "";
- for (int i = 0; i < res.Length; i++)
- {
- res += res[i] + "" res[i].
- }
- asciiLabel.Text = starsCh.ToString();
- // 4. Solve this puzzle:
- string puzzle = "NOW IS ZHEremove-me ZIME FOR ALL GOOD MEN ZO COME ZO ZHE AID OF ZHEIR COUNZRY.";
- // Once you fix it with string helper methods, it should read:
- // Now is the time for all good men to come to the aid of their country.
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment