INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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.

RE: C# programming help needed

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.

RE: C# programming help needed

(OP)
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!

RE: C# programming help needed

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
http://blogs.msmvps.com/craigber

RE: C# programming help needed

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close