C# programming help needed
C# programming help needed
(OP)
Hi all. I hope someone is there who can explain a couple of things to me in C#.
I keep getting "identifier expected" errors and don't know what that means. can someone show me an example line so I can see what it is I'm doing wrong?
Also, I get "; expected" errors. But there is a ";" at the end of the line. Where is it to go?
My program asks the user to enter a speed <in seconds> and then calculates
The lines read as:
m = 9.8; // meters //
s = 60; // time converted hours to seconds (squared) //
g = m/s * s; // this is the line for ; error //
// then the answer is to displayed on the screen. I didn't include the Console lines //
At least the above I think would work if the ; error would quit coming up. I hope I've
explained my problems clear enough. If not . . .
I haven't done programming in a long time and some of the terms are confusing. Any help will be appreciated.
I keep getting "identifier expected" errors and don't know what that means. can someone show me an example line so I can see what it is I'm doing wrong?
Also, I get "; expected" errors. But there is a ";" at the end of the line. Where is it to go?
My program asks the user to enter a speed <in seconds> and then calculates
The lines read as:
m = 9.8; // meters //
s = 60; // time converted hours to seconds (squared) //
g = m/s * s; // this is the line for ; error //
// then the answer is to displayed on the screen. I didn't include the Console lines //
At least the above I think would work if the ; error would quit coming up. I hope I've
explained my problems clear enough. If not . . .
I haven't done programming in a long time and some of the terms are confusing. Any help will be appreciated.
RE: C# programming help needed
If you code looks good at the point that the debugger is complaining, then "; expected" and "identifier expected" errors tend to be caused by typos or missing characters further up in your code.
RE: C# programming help needed
I dropped the class. Maybe next winter I'll take it again. Maybe by then the bugs in the program will be fixed.
Thanks again for your reply. No more help is needed from anyone. I don't want you to waste your time on this.
Kudos to all anyway. I'm glad there is a Programming section on tek-tips. Great job!
RE: C# programming help needed
- Don't use single characters for most variable names (loop counters are the exception). Code should be self-documenting, meaning you can figure out what it's doing by reading the code. Variable names like m, s, and g give no information about what the variable means. Comments should not be used to tell you what is stored in the variable.
- What are the data types for m, s, and g?
Craig Berntson
.Net MVP, Author, Tech Presenter
http://blogs.msmvps.com/craigber
RE: C# programming help needed
ReadLine() (assuming this is what you use) takes a string input so you must cast it before trying to perform mathematical calculations against the input.
C# is strongly typed and case sensitive, as craigber states, without seeing the code and variable declarations (data typing) it's hard to give further advice.
The error could be a typo on a line above where the error is identified, without seeing actual code, we are simply stabbing in the dark.
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music