Hello all,
im new here. Is this where beginners can ask stupid c# questions? or is there another section somewhere?
i will post now and im sure it can get moved to the relevant location if this isnt it.
anyway following a app tutorial on youtube, loving it.
but in the code:
to take this error away, he has to make the ChooseAction method static. Why does this have to be done? I thought static was only reserved for specific requirements. I understand what static is, it makes the variable or method available to the entire program right?
but i dont understand why that method was made static. Sorry very new to all this. please help if you can.
lastly, are method names started with a capital like OpenDoor
and are variables lower like frontDoor?
cause i see a few inconsistencies.
im new here. Is this where beginners can ask stupid c# questions? or is there another section somewhere?
i will post now and im sure it can get moved to the relevant location if this isnt it.
anyway following a app tutorial on youtube, loving it.
but in the code:
to take this error away, he has to make the ChooseAction method static. Why does this have to be done? I thought static was only reserved for specific requirements. I understand what static is, it makes the variable or method available to the entire program right?
but i dont understand why that method was made static. Sorry very new to all this. please help if you can.
C#:
int action = ChooseAction();
lastly, are method names started with a capital like OpenDoor
and are variables lower like frontDoor?
cause i see a few inconsistencies.
C#:
using CarClassLibrary;
using System;
namespace CarShopConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to the car store. First you must create some car inventory. Then you may add some cars to the shopping cart. Finally you can checkout which will give you the value of the shopping cart.");
int action = ChooseAction();
while (action != 0)
{
}
Console.ReadLine();
}
public static int ChooseAction ()
{
int choice = 0;
Console.WriteLine("Choose an action: \n(0) to quit \n(1) to add to inventory (2) to add a car to cart (3) to checkout");
choice = int.Parse(Console.ReadLine());
return choice;
}
}
}