Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
AnswerRe: What is this C# console compile error and how do I fix it? Pin
jschell16-Aug-12 11:05
jschell16-Aug-12 11:05 
GeneralRe: What is this C# console compile error and how do I fix it? Pin
Xarzu16-Aug-12 11:19
Xarzu16-Aug-12 11:19 
GeneralRe: What is this C# console compile error and how do I fix it? Pin
Wes Aday16-Aug-12 11:31
professionalWes Aday16-Aug-12 11:31 
GeneralRe: What is this C# console compile error and how do I fix it? Pin
Eddy Vluggen16-Aug-12 13:29
professionalEddy Vluggen16-Aug-12 13:29 
GeneralRe: What is this C# console compile error and how do I fix it? Pin
Eddy Vluggen16-Aug-12 13:31
professionalEddy Vluggen16-Aug-12 13:31 
AnswerRe: What is this C# console compile error and how do I fix it? Pin
Bernhard Hiller16-Aug-12 21:19
Bernhard Hiller16-Aug-12 21:19 
GeneralRe: What is this C# console compile error and how do I fix it? Pin
OriginalGriff16-Aug-12 21:38
mveOriginalGriff16-Aug-12 21:38 
AnswerRe: What is this C# console compile error and how do I fix it? Pin
OriginalGriff16-Aug-12 21:23
mveOriginalGriff16-Aug-12 21:23 
It's worth noting here the difference between static and non-static methods, properties and what-not, because it is important, and quite a bit fundamental. Bear with me.

Let's think about the real world: take cars.
How many wheels has a car? Simple question, simple answer: four. A car has four wheels (because if it had two it would be a motorbike). We can happily ask this of any car and expect the same answer.
What colour is a car? Eh? What? You can't ask that, because all cars are not the same colour. My car is Red, your car is Green, that car is Silver, this car is Black. You need to refer to a specific car in order to ask the question.

We call the "Number of wheels" a static property, and "Colour" a non-static property.

Every executable must have one - and only one - static Main method. This is the method that is executed by the framework when you application starts. Hence the need to be static, there must be a single instance of the method that is applicable to the whole application. It cannot be class instance based.
So if you are executing a static method, you do not have a class instance to refer to (or it wouldn't be static, it would be a class related method) So you can't call class related (or non-static) methods from static code without creating (or otherwise fetching) a class instance for them to refer to.

Unless you declare something as static (or in a class declared as static) then it is always non-static - because most of the code you create will be non-static.

So either your GetAverageSalary method needs to be static, or you need to put it in a class and create a class instance in order to access it, as the others have said.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

GeneralRe: What is this C# console compile error and how do I fix it? Pin
BobJanova16-Aug-12 22:51
BobJanova16-Aug-12 22:51 
GeneralRe: What is this C# console compile error and how do I fix it? Pin
OriginalGriff16-Aug-12 23:41
mveOriginalGriff16-Aug-12 23:41 
AnswerRe: What is this C# console compile error and how do I fix it? Pin
Richard MacCutchan16-Aug-12 21:29
mveRichard MacCutchan16-Aug-12 21:29 
Questiongetting a method progress percentage Pin
Mostafa M.A16-Aug-12 10:29
Mostafa M.A16-Aug-12 10:29 
AnswerRe: getting a method progress percentage Pin
Eddy Vluggen16-Aug-12 10:50
professionalEddy Vluggen16-Aug-12 10:50 
GeneralRe: getting a method progress percentage Pin
Mostafa M.A16-Aug-12 11:57
Mostafa M.A16-Aug-12 11:57 
GeneralRe: getting a method progress percentage Pin
Eddy Vluggen16-Aug-12 13:26
professionalEddy Vluggen16-Aug-12 13:26 
QuestionC# code snippet for InfoPath form Pin
dmsWebDev16-Aug-12 5:12
dmsWebDev16-Aug-12 5:12 
AnswerRe: C# code snippet for InfoPath form Pin
Wes Aday16-Aug-12 5:19
professionalWes Aday16-Aug-12 5:19 
GeneralRe: C# code snippet for InfoPath form Pin
dmsWebDev16-Aug-12 5:30
dmsWebDev16-Aug-12 5:30 
QuestionDont know how to create a storage procedure to Pin
paddymega16-Aug-12 1:39
paddymega16-Aug-12 1:39 
AnswerRe: Dont know how to create a storage procedure to Pin
Shameel16-Aug-12 1:41
professionalShameel16-Aug-12 1:41 
GeneralRe: Dont know how to create a storage procedure to Pin
paddymega16-Aug-12 3:00
paddymega16-Aug-12 3:00 
QuestionRe: Dont know how to create a storage procedure to Pin
Eddy Vluggen16-Aug-12 3:12
professionalEddy Vluggen16-Aug-12 3:12 
AnswerRe: Dont know how to create a storage procedure to Pin
paddymega16-Aug-12 5:11
paddymega16-Aug-12 5:11 
GeneralRe: Dont know how to create a storage procedure to Pin
Eddy Vluggen16-Aug-12 5:24
professionalEddy Vluggen16-Aug-12 5:24 
GeneralRe: Dont know how to create a storage procedure to Pin
paddymega16-Aug-12 6:00
paddymega16-Aug-12 6:00 

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.