|
-
Jul 20th, 2007, 04:49 AM
#1
Thread Starter
Hyperactive Member
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#
If anyone could suggest a book then that would be great too.
nuff rambling, thanks for any help guys and gals
gaz
-
Jul 20th, 2007, 04:59 AM
#2
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.
Last edited by stimbo; Jul 20th, 2007 at 05:35 AM.
-
Jul 20th, 2007, 08:08 AM
#3
Re: VB.NET Developer looking for C# Help
-
Jul 20th, 2007, 09:15 AM
#4
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#).
-
Jul 20th, 2007, 09:27 AM
#5
Re: VB.NET Developer looking for C# Help
 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.
-
Jul 20th, 2007, 10:09 AM
#6
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#.
-
Jul 24th, 2007, 05:29 AM
#7
Thread Starter
Hyperactive Member
Re: VB.NET Developer looking for C# Help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|