Beginning Visual C# Exercises - Chapter 06
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;
}
}
|