I made some changes to your source code and that works fine for me
please check the code below
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
struct Order
{
public string itemName;
public int unitCount;
public double unitCost;
public double totalCost()
{ return unitCost * unitCount;
}
}
static void Main(string[] args)
{
Order myOrder;
Console.WriteLine("Please enter the name of the item you would like to purchase.");
myOrder.itemName = Console.ReadLine();
Console.WriteLine("Thank you. Now please enter the number of items you would like to purchase.");
myOrder.unitCount = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Thank you. Now please enter the cost of a {0}.", myOrder.itemName);
myOrder.unitCost =Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Thank you! The total cost of your {0} orders of item {1} is {2}.", myOrder.unitCount, myOrder.itemName,myOrder.totalCost());
Console.ReadKey();
}
}
}
In your code u defined
itemName myItem;, am also confused on this,Is it possible to declare a variable like this?
You defined the struct in main function,Its better to place outside the main.
Also without declaring a struct variable is it possible to access its members?
syntax for calling a function is not like this in your code
please don't mark this as answer because I am also a beginner like you so someone else also verify this one.