Page 1 of 1
Want to start learning C#
Posted: Thu Jan 26, 2012 7:46 am
by Skillful
Hey guys I want to start learning C# from scratch.
Can you guys recommend me how and from where do I start?
I have Visual C# Express Edition installed.
Re: Want to start learning C#
Posted: Thu Jan 26, 2012 12:52 pm
by CodenStuff
Well you have C# installed so thats a good start lol.
Just do as you did with VB and read through tutorials to pick up the syntax to learn how to use it. A good way to see the differences between how you code something in VB and how to do that in C# is to use a convertor like:
http://www.developerfusion.com/tools/co ... to-csharp/
For example heres a few common things in VB:
Code: Select allDim Picture as bitmap = my.resources.horse
Picturebox1.image = Picture
For i = 0 to 100
Label1.text = i
next i
msgbox("Hello World")
And this is how it looks when converted to C#:
Code: Select allbitmap Picture = my.resources.horse;
Picturebox1.image = Picture;
for (i = 0; i <= 100; i++) {
Label1.text = i;
}
Interaction.MsgBox("Hello World");
You just have to read up on it and try things out cooll;
Re: Want to start learning C#
Posted: Thu Jan 26, 2012 1:57 pm
by MrAksel
Sorry Craig, but that is wrong. Conversions in C# are very strict, so you have to use i.ToString() in the for loop. And it is reapply important to remember that C# is case sensitive.
Re: Want to start learning C#
Posted: Thu Jan 26, 2012 2:41 pm
by Zulf
Code: Select allBitmap picture = Image.FromFile("/horse.png");
pictureBox1.Image = (Image)picture;
for (i = 0; i <= 100; i++) {
label1.Text = i.ToString();
}
MessageBox.Show("Hello World!");
Is correct. It's better to load images from an external directory. Saves resources and the program loads slightly faster.
Re: Want to start learning C#
Posted: Thu Jan 26, 2012 2:45 pm
by CodenStuff
Yeah yeah yeah I was just giving an example of the convertor lol
Re: Want to start learning C#
Posted: Thu Jan 26, 2012 2:45 pm
by MrAksel
Since Bitmap is derived from Image you do not need a cast to set the picturebox's image.
Re: Want to start learning C#
Posted: Thu Jan 26, 2012 6:28 pm
by Axel
Noone eff'in cares...
Re: Want to start learning C#
Posted: Thu Jan 26, 2012 10:04 pm
by Cheatmasterbw
C# isn't all that different from VB. The major difference is in things like variable declaration, If statements, case sensitivity, and syntax.
Message Boxes:
Code: Select all'VB'
msgbox(...)
'or'
messagebox(...)
If Statements:
Variable Declaration:
Code: Select all'VB'
Dim X as Integer = 5
Dim Y as String = "ASDF"
Dim Z as Boolean = true
Code: Select all//C#
int X = 5;
string Y = "ASDF";
bool Z = true;