Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# programming help needed

Status
Not open for further replies.

nelljack

Technical User
Dec 23, 2001
337
US
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.
 
Unless what you are working on is sensitive, it would be helpful to see a complete code snippet of the current function.

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.
 
Thanks RyanSW for your reply. I would send you my entire program but the software deleted all my lines when I opened it up. I only had 3 lines left to fix too.

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!
 
The best I think we can do is give you general advice here.....

- 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
 
Just to add my observation, you say you ask the user for input.

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top