🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

C# Workshop - Week 1 (Ch. 1 - 4) - Beginners

Started by
91 comments, last by CalebGorde 12 years, 10 months ago
Quote: Original post by M-E
Quote: Original post by Exershio
Is it just me or does C++ seem a hell of a lot easier? I started learning C++ a couple months ago, and have a firm grasp on the language, but jeez, C# is confusing the hell out of me. It may be just the spec we are reading.

I'm going to reread Chapter 1 again right now and see if it helps to understand it.


IMO C# looks a lot easier than C++. But that may be because i have a Java background.

It's more than just an impression.

Quote:
C# seems to be more Java-oriented than C++ oriented, am I right? (I'n not a C++ buff, so I can't judge)

I mean:

C#:
*** Source Snippet Removed ***

Java:
*** Source Snippet Removed ***

Yes, java and C# look very much alike. This was probably one of the design goals, to make the transition easier. It looks like they took a good look at java, threw away the bad stuff, took some good stuff from C++ and other languages, and voilà. It's a typical advantage of younger languages.
Advertisement
JWalsh, I'm so glad to see you created a n00b thread to go alongside the intermediate/advanced one. I had deliberately kept away from the workshop forum since Wednesday as I wanted to do as much reading & playing with simple code as possible before I ventured back into the workshop thread.
I've just had a quick read through this new thread and it's just the sort of thing I need right now with just the right level of content so many thanks. I for one would would certainly benefit from having an additional beginners thread to accompany the main one for the first 3 or 4 weeks. I appreciate you and the rest of the tutors must be burning the candle at both ends for our benefit. Thank you.

I was struggling like mad to get my head around all the concepts until ChaosUK posted the link to PublicJoe's site. Another one I have found extremely useful is video Introduction to the C# Programming Language on this site:
http://msdn.microsoft.com/vstudio/express/beginner/learningpath/default.aspx
(sorry if it's already been posted)

What a relief too that we have another week to digest the early material.

I think what I have found most difficult about the 1st couple of chapters in the specification is the sheer amount of terms & definitions to remember, coupled with the somewhat clinical writing style. It's been total information overload.

Anyway, good news for me at least, I've had a particularly productive couple of days and things are now sinking in and coming together in my mind. Also, my shift patterns are changing too which should give me 2 days off during the week so I can really get down to some serious study with the house to myself.

Give me 2 or 3 more days and I will probably be back with some (hopefully sensible) questions.

Thanks once again
Vod

ps. Shawn, glad to see I'm not the only old duffer trying to learn to program (37 going on 38 here) How're your eyes holding up? I reckon I'll need glasses by the end of the final project! :)
For some people this page may be of use to help them get started, it helped me.
http://www.functionx.com/csharp/
Ok I experimented with the code, because that's how I learn.

I tried intergrading this into a GUI interface.

I keep the same code but change the output.

Instead of writeline I have it Textbox1.text.

My question is, how do I convert an int to a string?

because in order to have z.HP be in that textbox, it has to be a string not int.

I tried

z.HP1 = cstr(z.HP)

but than i get errors

Thanks for the help.

-Zac Karpinski

*Sorry if this isn't suppose to be in here but it's related.

Quote: Original post by zKarp
Ok I experimented with the code, because that's how I learn.

I tried intergrading this into a GUI interface.

I keep the same code but change the output.

Instead of writeline I have it Textbox1.text.

My question is, how do I convert an int to a string?

because in order to have z.HP be in that textbox, it has to be a string not int.

I tried

z.HP1 = cstr(z.HP)

but than i get errors

Thanks for the help.

-Zac Karpinski

*Sorry if this isn't suppose to be in here but it's related.

int x = 1;string xs = x.ToString();
The other option is to use the convert static class.

int i = 3;
string b = Convert.ToString(i);

theTroll
Quote: Original post by SamLowry
int x = 1;string xs = x.ToString();


Quote: Original post by TheTroll
The other option is to use the convert static class.

int i = 3;string b = Convert.ToString(i);


theTroll



Thanks
Quote: Original post by SamLowry
Quote: Original post by zKarp
Ok I experimented with the code, because that's how I learn.

I tried intergrading this into a GUI interface.

I keep the same code but change the output.

Instead of writeline I have it Textbox1.text.

My question is, how do I convert an int to a string?

because in order to have z.HP be in that textbox, it has to be a string not int.

I tried

z.HP1 = cstr(z.HP)

but than i get errors

Thanks for the help.

-Zac Karpinski

*Sorry if this isn't suppose to be in here but it's related.

int x = 1;string xs = x.ToString();

Or xs = "" + x;

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Hey, thanks for this kind of simplified introduction, I was finding the chapters of the spec quite difficult to read.

Anyway just a few questions on the example code in the explanation of expressions. Just a bit of code that I don't know what it is.


rand.Attack(Semirhage);

This bit of code as far as I can tell, is essentially saying, using rand's stats, call the method Attack (is it a method? The thing called attack in the Character class anyway) on Semirhage's stats.
I think that the character fight class has already created a new instance of the class character (is this an object now then?) and this is just using a method from that class?
But I would like to know what this kind of thing is called, does this have a special name? Or is it really simple and I'm just lost.

Also:

public void Attack(Character enemy)

By my mind, this is a name of a method, and this is the Attack being called from before, but my question is about the brackets. What is this called, I presume this isn't an extended name of a method, but this is assigning that whenever this gets called, the thing that would be hit will be called enemy, right?

resistance = enemy.Level + enemy.Armor;

And this is used in this line for example?:



Sorry if I make little sense. I come from having no programming experience or knowledge at all so go easy on me.

I would like to say thanks to JWalsh and all the others who are putting this workshop together and making it what it is. I would like to see a few more of these basic introductions but I understand how people to whom this is really basic stuff might be a little bored. Thanks again.

[Edited by - Spooneh on July 9, 2007 9:22:57 AM]
Im not a teacher, just learning too, but maybe i can help a lil (or confuse you even more T_T)

I think you mostly have it correct with what your saying

rand.Attack(Semirhage);
is calling rand attack method and naming Semirhage as the target

Semirhage would be a object that is being passed into rand attack method

This line is directly connected to that
public void Attack(Character enemy)
This is defining the method and saying what objects/variable it accepts

So attack takes a object of type Character and calls it enemy for the duration of the method

Your next line confused me, but basically ill use it all in an example

public void Attack(Character enemy) {

int resistance = enemy.Level + enemy.Armor;
int damageBySword = 10;

enemy.takeDamage(damageBySword - resistance);

}

So
rand has a sword that can deal 10 damage
Semirhage level is 3 and he has a armour of 5, so resistance would be 8
if Semirhage has 10 life, then after rand uses

rand.Attack(Semirhage);

Semirhage life would now be 8
10 damage minus the 8 resistance means 2 damage is then taken from Semirhage life

Hope that helps at all

This topic is closed to new replies.

Advertisement