Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# TakePicture in Canon Pin
Richard MacCutchan14-Mar-19 23:04
mveRichard MacCutchan14-Mar-19 23:04 
QuestionC# When I get Focallength find errs. Pin
Member 1415621214-Mar-19 21:02
Member 1415621214-Mar-19 21:02 
AnswerRe: C# When I get Focallength find errs. Pin
Richard MacCutchan14-Mar-19 23:03
mveRichard MacCutchan14-Mar-19 23:03 
GeneralRe: C# When I get Focallength find errs. Pin
Member 1415621218-Mar-19 15:36
Member 1415621218-Mar-19 15:36 
Questiondynamic URL for soap webservice Pin
Member 302085113-Mar-19 22:46
Member 302085113-Mar-19 22:46 
AnswerRe: dynamic URL for soap webservice Pin
dan!sh 14-Mar-19 5:27
professional dan!sh 14-Mar-19 5:27 
QuestionTrying to find the problem in this simple C$ program Pin
Brian_TheLion13-Mar-19 20:16
Brian_TheLion13-Mar-19 20:16 
AnswerRe: Trying to find the problem in this simple C$ program Pin
OriginalGriff13-Mar-19 21:09
mveOriginalGriff13-Mar-19 21:09 
You declare Main:
C#
public void Main(string[] args)
    {
    ReadHeader();
    ReadVerbs();
    ReadNouns();
    ReadObjects();
    ReadStartRoom();
    ReadRooms();
    ReadMessages();
    ReadAutoActions();
    ReadActions();
    Console.Read();
    }
But it is not declared as static, just as the error message says.
When you declare a method like this:
C#
public void MyMethod(ParameterType parameter)
    { ... }
You create an instance method: which means that it needs an instance of it's containing class in order to be used.

Think about cars for a moment: what colour is your car? What colour is my car? What colour is that car - that one, over there, next to the lamppost with the cat sitting on the roof?
Those are all questions you can ask, because you are specifying which car you are referring to: Your car is green, my car is black, that car - that one, over there, next to the lamppost with the cat sitting on the roof is red. It is an Instance Question - it requires an instance of a car to be specified in order to be asked.
You can't ask "what colour is a car?" (or more accurately you can't answer that) because not all cars are the same colour.
But you can ask "how many wheels has a car?" because all cars have four wheels (if it had 2 it would be a motorbike, and three would be a trike). "How many wheels?" is a static question, because you do not need an instance of a car to ask it.

Classes and methods are the same: Instance methods need an instance in order to be used, static methods don't.

And the Main method is where your code starts executing, so it can't have an instance as nothing exists to create an instance (and of what?) before Main is called.

And that is what the error is saying: "There is no static Main method I can call to start the code running".
Add the static keyword to your Main method declaration, and the error will go away:
C#
public static void Main(string[] args)
    {
    ReadHeader();
    ReadVerbs();
    ReadNouns();
    ReadObjects();
    ReadStartRoom();
    ReadRooms();
    ReadMessages();
    ReadAutoActions();
    ReadActions();
    Console.Read();
    }

Of course, that will produce more errors because your other methods are also instance methods, but I think you can probably start to fix them...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!


modified 14-Mar-19 4:55am.

GeneralRe: Trying to find the problem in this simple C$ program Pin
Brian_TheLion13-Mar-19 23:13
Brian_TheLion13-Mar-19 23:13 
GeneralRe: Trying to find the problem in this simple C$ program Pin
OriginalGriff13-Mar-19 23:41
mveOriginalGriff13-Mar-19 23:41 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Brian_TheLion14-Mar-19 0:11
Brian_TheLion14-Mar-19 0:11 
GeneralRe: Trying to find the problem in this simple C$ program Pin
OriginalGriff14-Mar-19 0:26
mveOriginalGriff14-Mar-19 0:26 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Eddy Vluggen14-Mar-19 3:38
professionalEddy Vluggen14-Mar-19 3:38 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Richard MacCutchan13-Mar-19 23:52
mveRichard MacCutchan13-Mar-19 23:52 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Brian_TheLion13-Mar-19 23:59
Brian_TheLion13-Mar-19 23:59 
GeneralRe: Trying to find the problem in this simple C$ program Pin
OriginalGriff14-Mar-19 0:28
mveOriginalGriff14-Mar-19 0:28 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Richard MacCutchan14-Mar-19 1:51
mveRichard MacCutchan14-Mar-19 1:51 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Brian_TheLion14-Mar-19 0:28
Brian_TheLion14-Mar-19 0:28 
GeneralRe: Trying to find the problem in this simple C$ program Pin
OriginalGriff14-Mar-19 0:44
mveOriginalGriff14-Mar-19 0:44 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Brian_TheLion14-Mar-19 1:09
Brian_TheLion14-Mar-19 1:09 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Brian_TheLion14-Mar-19 1:19
Brian_TheLion14-Mar-19 1:19 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Richard MacCutchan14-Mar-19 1:54
mveRichard MacCutchan14-Mar-19 1:54 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Brian_TheLion14-Mar-19 1:57
Brian_TheLion14-Mar-19 1:57 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Richard MacCutchan14-Mar-19 2:16
mveRichard MacCutchan14-Mar-19 2:16 
GeneralRe: Trying to find the problem in this simple C$ program Pin
Brian_TheLion14-Mar-19 2:22
Brian_TheLion14-Mar-19 2:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.