Convert a VB statement to C#
-
Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance
-
Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance
-
Try this byte[] buffer = new byte[streamObj.Length + 1]; And don't forget to vote the message
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
-
Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance
-
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.
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
-
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
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 usestreamObj.Length
.Despite everything, the person most likely to be fooling you next is yourself.
-
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 usestreamObj.Length
.Despite everything, the person most likely to be fooling you next is yourself.
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
-
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
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.
-
Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance
Try this byte[] buffer= null; buffer=new byte[streamObj.length];
-
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.
-
Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance
byte[] buffer = new byte[streamObj.Length + 1];
-
Hi, Can abybody help me in converting the following VB statement to c# Dim buffer(streamObj.Length) As Byte. Thanks in Advance
Use Always for convertion......... http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx