Results 1 to 7 of 7

Thread: VB.NET Developer looking for C# Help

  1. #1

    Thread Starter
    Hyperactive Member tailz's Avatar
    Join Date
    Jul 2002
    Posts
    306

    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

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    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.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: VB.NET Developer looking for C# Help


  4. #4
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    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#).
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

  6. #6
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    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#.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  7. #7

    Thread Starter
    Hyperactive Member tailz's Avatar
    Join Date
    Jul 2002
    Posts
    306

    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 ) - 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

    The link from harding.edu I initally found very handy

    Cheers all

    gaz

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width