Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. Differences between vb.net and c#

Differences between vb.net and c#

Scheduled Pinned Locked Moved Clever Code
csharpquestion
22 Posts 14 Posters 19 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A adgonz

    The thing is that vb.net evaluates the comparison to Nothing when one of the operands is Nothing. And something like:

    If Nothing Then

    End If

    Is valid, even if you specify Option Strict On

    D Offline
    D Offline
    dojohansen
    wrote on last edited by
    #21

    But is Nothing True or Nothing False in the VB world? :p

    1 Reply Last reply
    0
    • A adgonz

      Do you think this two pieces of code are the same? C#

          private string f()
          {
              System.Nullable<System.Int32> a = null;
              System.Nullable<System.Int32> b = 7;
              if (a != b)
              {
                  return "apple";
              }
              else
              {
                  return "orange";
              }
          }
      

      vb.net

      Function f() As String
          Dim a As System.Nullable(Of System.Int32) = Nothing
          Dim b As System.Nullable(Of System.Int32) = 7
          If a <> b Then
              Return "apple"
          Else
              Return "orange"
          End If
      End Function
      
      M Offline
      M Offline
      Mauro Leggieri
      wrote on last edited by
      #22

      I didn't think it is a problem. In VB6 you must use the IS operator to check for Nothing values: If Var IS Nothing Then .... And I am almost sure that it was documented and the behavior you mention of comparing 2 variables when some o both are Nothing can give wrong results. Best regards, Mauro H. Leggieri

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups