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. Web Development
  3. ASP.NET
  4. Convert a VB statement to C#

Convert a VB statement to C#

Scheduled Pinned Locked Moved ASP.NET
csharphelp
12 Posts 8 Posters 0 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.
  • R reogeo2008

    Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance

    S Offline
    S Offline
    sumit7034
    wrote on last edited by
    #2

    Try this byte[] buffer = new byte[streamObj.Length + 1]; And don't forget to vote the message

    N 1 Reply Last reply
    0
    • S sumit7034

      Try this byte[] buffer = new byte[streamObj.Length + 1]; And don't forget to vote the message

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #3

      sumit7034 wrote:

      streamObj.Length + 1

      WHY?

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

      G 1 Reply Last reply
      0
      • R reogeo2008

        Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #4

        Bookmark this converter from VB.NET to C#[^]


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

        N 1 Reply Last reply
        0
        • B Blue_Boy

          Bookmark this converter from VB.NET to C#[^]


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #5

          Blue_Boy wrote:

          Bookmark this converter from VB.NET to C#[^]

          It works for simple statements not for all.

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

          1 Reply Last reply
          0
          • N N a v a n e e t h

            sumit7034 wrote:

            streamObj.Length + 1

            WHY?

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #6

            Because VB uses the highest index when declaring array, while C# uses the size. The code is an exact translation of the VB code, but the VB code is probably not correct in the first place. It should most likely use streamObj.Length - 1 to create a buffer the same size as the stream, and the translation of that to C# would use streamObj.Length.

            Despite everything, the person most likely to be fooling you next is yourself.

            N 1 Reply Last reply
            0
            • G Guffa

              Because VB uses the highest index when declaring array, while C# uses the size. The code is an exact translation of the VB code, but the VB code is probably not correct in the first place. It should most likely use streamObj.Length - 1 to create a buffer the same size as the stream, and the translation of that to C# would use streamObj.Length.

              Despite everything, the person most likely to be fooling you next is yourself.

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #7

              Guffa wrote:

              Because VB uses the highest index

              Great. It is new to me and thanks for correcting me. So it is not a zero based index?

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

              G 1 Reply Last reply
              0
              • N N a v a n e e t h

                Guffa wrote:

                Because VB uses the highest index

                Great. It is new to me and thanks for correcting me. So it is not a zero based index?

                All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #8

                Yes, it's zero based, but the upper limit in the Dim statement is the highest index in the array, not the size of the array. Dim buffer(3) As Byte 'declares an array with four bytes

                Despite everything, the person most likely to be fooling you next is yourself.

                J 1 Reply Last reply
                0
                • R reogeo2008

                  Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance

                  H Offline
                  H Offline
                  hemant kaushal
                  wrote on last edited by
                  #9

                  Try this byte[] buffer= null; buffer=new byte[streamObj.length];

                  1 Reply Last reply
                  0
                  • G Guffa

                    Yes, it's zero based, but the upper limit in the Dim statement is the highest index in the array, not the size of the array. Dim buffer(3) As Byte 'declares an array with four bytes

                    Despite everything, the person most likely to be fooling you next is yourself.

                    J Offline
                    J Offline
                    Jay_se
                    wrote on last edited by
                    #10

                    Great Guffa... nicely explained.

                    Jey

                    1 Reply Last reply
                    0
                    • R reogeo2008

                      Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance

                      S Offline
                      S Offline
                      Shaik Haneef
                      wrote on last edited by
                      #11

                      byte[] buffer = new byte[streamObj.Length + 1];

                      1 Reply Last reply
                      0
                      • R reogeo2008

                        Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance

                        S Offline
                        S Offline
                        Shaik Haneef
                        wrote on last edited by
                        #12

                        Use Always for convertion......... http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx

                        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