Results 1 to 11 of 11

Thread: Why VB.NET doesn't have ++ ?

  1. #1

    Thread Starter
    Fanatic Member sbasak's Avatar
    Join Date
    Aug 2001
    Location
    Globe Trotter
    Posts
    524

    Why VB.NET doesn't have ++ ?

    I wonder why ++ operator is missing in VB.NET where as we have other C equivalents like += +* etc..

    Any guess???

    In one book I read that Microsoft thought ++ will complicate the code! Then why not the same for +/ etc??
    Life is a one way journey, not a destination. Travel it with a smile and never regret anything.
    Yesterday is history, tomorrow is a mystery, today is gift - that's why we call it present.

  2. #2
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Post and preincrement are bad coding practice.
    This is because the second parameter is implied.

    Use +=1 instead.
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Talking about Cs , ++ is used in C# with For loops like this :


    int i;
    for (i=1 ; i <=10 ; i++) {
    Console.WriteLine("Number : " , i);

    the output is :1 through 10 .

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by MerrionComputin
    Post and preincrement are bad coding practice.
    This is because the second parameter is implied.

    Use +=1 instead.
    ??? Bad coding practice? Since when? I have been using it for a long time. All my C++ and C# books use it, even the MSDN library uses it. Where do you get this is bad coding practice.

  5. #5
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Yah, why not use i+=1 it's the same thing.

    int i;
    for (i=1 ; i <=10 ; i+=1) {
    Console.WriteLine("Number : " , i);
    }

    the output is :1 through 10 .
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  6. #6
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by Arc
    Yah, why not use i+=1 it's the same thing.

    int i;
    for (i=1 ; i <=10 ; i+=1) {
    Console.WriteLine("Number : " , i);
    }

    the output is :1 through 10 .
    You can do it, but the ++ operator can be used in other means besides incrementing a counter variable by 1. You can overload the operator in your C# class, and use it on an object. Such as if you had a object type that overloads the operator, you could have that object increment anything in the object, such as a property, value, etc.

    Therefor, using the i +=1 doesn't work in all situations, just the value types like integer. Maybe you want to do a for loop through an object or something.

    Basically, it provides some flexibility when programming, and that I welcome.

    One last reason to use ++ instead of +=1, less typing...lol.

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    hellswraith , I overloaded three voids in my C# class without any operators . How can you do that with ++ operators ?

  8. #8

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't get it hellswraith !! . Better I didn't use them in my voids .

  10. #10
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    In your voids?

    What are you talking about? Show me an example.

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    How can I overloads a function in C# with operators ? It seems not obligatory but preferable .
    Thanks

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