Subject: Beginning Visual C# Exercises - Chapter 06 Answers
Posted By: seblake Post Date: 9/24/2004 4:10:28 PM
1.    Function signature expects a return value but example provides none
        Parameter array "args" must be last declared in argument list

2.    if (args.Length >= 2)
        {
            string firstParam = args[0];
            int secondParam = Convert.ToInt32(args[1]);
            Console.WriteLine("Incoming arguments specify that {0} will occur {1} times.",
                firstParam, secondParam);
        }

3.    delegate string inputDelegate();
        static string reader()
        {
            return Console.ReadLine();
        }

        .... on to Main()

        inputDelegate getInput;
        Console.WriteLine("Enter your name:");
        getInput = new inputDelegate(reader);
        Console.WriteLine("Result: {0}", getInput());

4.    struct order
        {
            public string itemName;
            public int      unitCount;
            public double unitCost;

            public double howMuch()
            {
                return unitCount * unitCost;
            }

5.        public string orderInfo()
            {
                string badNews = "Order Information: " + Convert.ToString(unitCount) +
                    " " + itemName + " items at $" + Convert.ToString(unitCost) +
                    " each, total cost $" + Convert.ToString(howMuch());
                return badNews;
            }
        }

Go to topic 19740

Return to index page 765
Return to index page 764
Return to index page 763
Return to index page 762
Return to index page 761
Return to index page 760
Return to index page 759
Return to index page 758
Return to index page 757
Return to index page 756