/* attempt to deal with prototype, bootstrap, jquery conflicts */ /* for dropdown menus */

\$75

### Image of the Day Submit

IOTD | Top Screenshots

## c# help

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

7 replies to this topic

### #1cyril98  Members

Posted 11 December 2012 - 07:56 PM

hi guys i need some help whenever i compile code like this it comes up with random errors and i followed the book of ron pentons properly

class lexington
{
weapon = lazarus revolver
armor = military uni
level = 70
}

now i get these errors
; needed
undeclared variable which is strange because i have declared it

thanks

### #2Khaiy  Members

Posted 11 December 2012 - 10:56 PM

At a glance, I notice several things:

-Each statement needs a semicolon (;) after it
-Not having semicolons will screw up the rest of your code that comes after where it ought to be
-Individual variables cannot be separate words like "lazarus revolver"
-The variable types in the code are not declared

I suspect that there are more issues as well, but it's hard to say for certain what they would be based on this fragment of code alone. If you post more code I'll be able to help you more, and I don't want to make guesses about what you're doing based on this alone. But from what's already here, I think that you may want to spend some more time practicing C# syntax before tackling something game-sized.

I think it's unlikely that you're following Ron Penton's book correctly, given that code formatted as above will never compile in C#. As a good general rule, remember that errors aren't random. They always represent problems in your underlying code, and they contain highly relevant information (even if the relevance isn't clear).

-------R.I.P.-------

Selective Quote

~Too Late - Too Soon~

Posted 12 December 2012 - 06:35 AM

The post above is 100% correct, you really need to take the time to learn C# and it's syntax before going any further.

As for your code, I believe something along the lines of the following is what you were actually trying to achieve:

class Lexington
{
private String weapon = "lazarus revolver";
private String armor = "military uni";
private int level = 70;
}


### #4BCullis  Members

Posted 12 December 2012 - 10:40 AM

i followed the book of ron pentons properly

No, no you didn't.

I'm seriously having a "not sure if trolling" moment here. At any rate, the other posters have hit the nail on the head: you're not using correct C# syntax at all. Look at adt7's code, then look at your book again, and notice the things you left out.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

### #5cyril98  Members

Posted 12 December 2012 - 05:01 PM

could someone take a look at my code and please give me a few pointers thanks
i didnt mean to troll

### #6Khaiy  Members

Posted 12 December 2012 - 07:10 PM

I don't think that you're trolling. But you are being awfully vague in what sorts of "pointers" you're looking for. Based only on the code you posted above, the best advice I can give is to read up on C# syntax. MSDN has some great intro material that is free, though it can be a lot to absorb. I'd give a link, but I'm posting from my phone. I'll edit the link in when I get home. You can also post more code, so that we can get an idea of what you're trying to accomplish.

If you post back with a description of what you want the code fragment you posted to do, I can tell you how I might approach it.

Edited by Khaiy, 12 December 2012 - 08:37 PM.

-------R.I.P.-------

Selective Quote

~Too Late - Too Soon~

### #7cyril98  Members

Posted 12 December 2012 - 07:32 PM

thanks khaiy