VB.NET Developer looking for C# Help
Hi peeps,
I'm a VB.NET developer and have been for years now. Before that was VB6 and VB4 (before that was Turbo Pascal, Quick Basic and Quick C :)
As my job/career has "developed" I've recently started moving into the DirectX world and its clear that it wants me to code in C++ or C# and I am quite prepared to do so as converting code from C# to VB.NET is becoming rather tiresome.
Anyway, could anyone please give me examples of the differences I need to study in C# to VB.NET please? I am not looking for the blatently obvious e.g. variable declarations etc but a little more in depth differences. For example the differences in Event handling, multi-threading, error handling and Interfaces. I also notice stuff like
Code:
if (blah == functionName(z,y)) {
<do stuff>;
}
...and I actually am not 100% sure what the IF statement is testing. So then again, maybe I do need a newbies guide to C# :D
If anyone could suggest a book then that would be great too.
nuff rambling, thanks for any help guys and gals
gaz
Re: VB.NET Developer looking for C# Help
This is meant to be a good C# book:
Murach's C# 2005
Looking to move into C# myself and plan to get it. I know someone who has it who really likes it. Very 'real' (i.e. practical) examples which help lots.
Here's a link to Chapters 2 & 3 if you want to have a quick look:
2 Free Chapters
Chapter 2 is very basic and probably not much use if you are already familar with .NET, chapter 3 starts showing some C# code. You can also download ALL the code used in all the chapters as a Zip file which will give you quite a nice collection of code examples that are used throughout the book.
Re: VB.NET Developer looking for C# Help
Re: VB.NET Developer looking for C# Help
There a nice little O'Reilly book named "C# & VB.NET Conversion" by Jose Mojica, which unfortunately was never kept up to date beyond 2003.
Also, check out the various on-line and commercial (trial/demo) VB to C# converters.
Regarding "blah == functionName(z,y)": putting the value to test at the beginning is an old C holdover that is unnecessary in C#. (It's purpose was to help avoid accidentally using an assignment instead of an equality comparison - C# requires 'if' conditionals to always be a boolean test, so you can't accidentally use an assignment where you want an equality test in C#).
Re: VB.NET Developer looking for C# Help
Quote:
Originally Posted by David Anton
[...] C# requires 'if' conditionals to always be a boolean test, so you can't accidentally use an assignment where you want an equality test in C#).
That's not to say that you can't include assignments in conditional expressions, though, but you need to make sure that the expression evaluates to either true or false overall.
Code:
int var;
if ((var = somefunc()) > 0)
In case tailz is confused: assignment and equality are two different operators in C-based languages: = and ==, respectively.
Moved from VB.NET.
Re: VB.NET Developer looking for C# Help
Right - as I said, the overall conditional must evaluate to a boolean test.
But the compiler will catch the sloppy cases (when coding in C/C++ the compiler doesn't) so there's no need for the "blah == functionName()" kludge in C#.
Re: VB.NET Developer looking for C# Help
Awesome cheers guys.
Actually made a boo-boo in original post and was sposed to be using the assignment operator DOH, so basically I suggested I didnt even know what an if statement did lol :]
What I was sposed to say is I didnt understand what part of the IF that the following would be testing.
Code:
int var;
if ((var = somefunc()) > 0) {
}
As I understand it now, the result of somefunc() goes into "var" and then the if does the boolean on "var" (if it was a bool)... That Right? :)
I'm a competent coder (honest :D) - I'm already starting to read some of it without rearranging the code into VB.NET in me head which is good, tis what you're used to I guess.
anyway the links have proved very useful and I may order a couple of those books cheers :D
The link from harding.edu I initally found very handy
Cheers all
gaz