473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to convert statment

how to convert this statement to vb.net???
byte[] buffer = new Byte[checked((uint)Math.Min(4096,
(int)fileStream.Length))];

Mar 13 '06 #1
3 1644
Instant VB produces:
Dim buffer As Byte() = New Byte((CUInt(Math.Min(4096,
CInt(fileStream.Length)))) - 1){}

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"Ar*********@gmail.com" wrote:
how to convert this statement to vb.net???
byte[] buffer = new Byte[checked((uint)Math.Min(4096,
(int)fileStream.Length))];

Mar 13 '06 #2

Ar*********@gmail.com wrote:
how to convert this statement to vb.net???
byte[] buffer = new Byte[checked((uint)Math.Min(4096,
(int)fileStream.Length))];


Dim buffer As New Byte(Math.Min(4096, CInt(fileStream.Length))) {}

I am slightly mystified as to why the cast to uint is there in the
original. Note that I have left in the perhaps-redundant cast to Int32
of fileStream.Length, so that the original's behaviour (throwing an
exception if fileStream.Length can't fit in an Int32) is preserved.
Note also that VB.NET's overflow checking can't be controlled as
grainily as C#'s checked/unchecked allows; this is controlled at
application level; the default is to check everything.

--
Larry Lard
Replies to group please

Mar 13 '06 #3
Be aware of 1-off errors: in VB, you specify the upper bound of the array,
while in C# you specify the length of the array (there differ by 1).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"Larry Lard" wrote:

Ar*********@gmail.com wrote:
how to convert this statement to vb.net???
byte[] buffer = new Byte[checked((uint)Math.Min(4096,
(int)fileStream.Length))];


Dim buffer As New Byte(Math.Min(4096, CInt(fileStream.Length))) {}

I am slightly mystified as to why the cast to uint is there in the
original. Note that I have left in the perhaps-redundant cast to Int32
of fileStream.Length, so that the original's behaviour (throwing an
exception if fileStream.Length can't fit in an Int32) is preserved.
Note also that VB.NET's overflow checking can't be controlled as
grainily as C#'s checked/unchecked allows; this is controlled at
application level; the default is to check everything.

--
Larry Lard
Replies to group please

Mar 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dib | last post by:
Hi, I have this statment in VB6 how do I make it work in Dot net program. Dim oForm as Form If rs.Fields("OpenFM").Value = "F" Then strSqlFName = "SELECT * from tblmenudesc where...
1
by: Me, Myself, and I | last post by:
First off, i apologize if my terminology is off... I am currently in a project that is basically a front-end to a database. In coding this, I am taking into account that it has the *potential*...
3
by: Omer kamal | last post by:
Dear all, I want to save my data into MS Access database Table which consist of some fields with short date and short time formats. I try to save data in to the said table and I am getting error...
15
by: angellian | last post by:
Sorry to raise a stupid question but I tried many methods which did work. how can I conserve the initial zero when I try to convert STR(06) into string in SQL statment? It always gives me 6...
1
by: Aaron_nesbitt | last post by:
Hi, Is there any way to convert a sting (Pulled from a data tabel) into VB.NET code? The original case statment looked like this: Select Case e.Link.ItemName Case "frmNEWFORM" Dim f As...
5
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used...
4
by: huzzaa | last post by:
I am using a switch statement that will decide from a random number what message to display. I want the random number to be between 0 and 100 and then if the number is say between 1 and 10 to...
1
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt...
10
by: cmdolcet69 | last post by:
Public ArrList As New ArrayList Public bitvalue As Byte() Public Sub addvalues() Dim index As Integer ArrList.Add(100) ArrList.Add(200) ArrList.Add(300) ArrList.Add(400) ArrList.Add(500)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.