Just wanted to put this out to help anyone, and if anyone sees anything incorrect or if they believe they have a better answer. Go ahead and point out any errors or helpers if you want.
1. a) Return type does not equal to return value
b) This one im not so sure i think you don't need the params in front of int[] args, or that the parmeters don't match
2. a) seems theres 2, twos
I had entered a string named: "String" and a int: 10 into my command line arguements
static void Main(string[] args)
{
string myString = args[0];
int myInt = Convert.ToInt32(args[1]);
Console.WriteLine("{0} command line arguments were specified:", args.Length);
Console.WriteLine("The string command line was: {0}\nThe int command line was: {1}",
myString, myInt);
}
2. b)
class Class1
{
delegate string impersonateDelegate();
static string input()
{
return Console.ReadLine();
}
static void Main(string[] args)
{
Console.WriteLine("Please enter a string:");
impersonateDelegate impersonate = new impersonateDelegate(input);
string myString = impersonate();
Console.WriteLine("Your string was {0}", myString);
}
}
3 and 4)
Seemed like these where similiar problems so I just joined them into one app. You don't really need the info in main since it just asked for a function in the struct on 4. But I just wanted to be able to interact with it and see it work.
class Class1
{
struct order
{
public string itemName;
public int unitCount;
public double unitCost;
public double Total()
{
return unitCount * unitCost;
}
public string TotalCost()
{
return "Order information: " + unitCount + " " + itemName + " items at $" + unitCost
+ " each, total cost $" + Total();
}
}
static void Main(string[] args)
{
order orderTotal;
orderTotal.itemName = "CD";
orderTotal.unitCost = 15;
Console.WriteLine("How many {0}'s do you want:", orderTotal.itemName);
orderTotal.unitCount = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(orderTotal.TotalCost());
}
}