1.6: Challenge Answers

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0._03_Strings_Challenges
{
    class Program
    {
        static void Main(string[] args)
        {


            /**** Bronze ***/
            string aString = string.Format("I heard him say \"What's up?\"");
            Console.WriteLine(aString);

            string myString = string.Format("{0:C}", 123.45);
            Console.WriteLine(myString);

            string bString = string.Format("{0:P}", .123);
            Console.WriteLine(bString);

            string phoneString = string.Format("My phone number is: {0: (###)-###-####}", 1234567890);
            Console.WriteLine(phoneString);

            string instructor = "Paul";
            string instructor2 = "Gavin";
            string confusedItemOne = "jQuery";
            string confusedItemTwo = "objects";
            string confusedItemThree = "functions";

            Console.WriteLine("Hello " + instructor + " and " + instructor2 + " I'm doing great, but I'm still struggling with " + confusedItemOne + ", " + confusedItemTwo + ", " + confusedItemThree + ".");

            /*** Silver Answer ***/
            string potentialEmployerName = "Mr. Jones";
            string date = DateTime.Today.ToShortDateString();

            string str = "Dear " + potentialEmployerName + ". Today is " + date + ".";
            string messageUnderstand = " I'm enjoying class. I think I like C# the best out of anything.";
            string messageGoal = " I'd like to get a job as a developer after I finish this course.";

            str += messageUnderstand;
            str += messageGoal;

            Console.WriteLine(str);

            /*** Gold ***/

            string usernameLow = @"jamespauloconnor";
            string usernameUp = @"JAMESPAULOCONNOR";

            bool result = usernameLow.Equals(usernameUp, StringComparison.OrdinalIgnoreCase);
            bool resultTwo = usernameLow.Equals(usernameUp, StringComparison.Ordinal);

            Console.WriteLine("{0} and {1} are {2}", usernameLow, usernameUp,
                                result ? "equal." : "not equal.");

            Console.WriteLine("{0} and {1} are {2}", usernameLow, usernameUp,
                                resultTwo ? "equal." : "not equal.");

            Console.ReadLine();
        }
    }
}

Last updated