Another C# To VB.net ? how so?

  • Thread starter Thread starter Smoke
  • Start date Start date
S

Smoke

I have found another small code from C# that i cannot convert.
My goal is to convert an existing EXIF metadata reader that is on C# to VB.net ... maybe someone already know of one made for VB.net
and can solve my problem..?

Besides, here is the code, i have no idea what |= is in VB.net

public EXIFRational(byte[] data)
{
Denominator = 0;
Numerator = 0;
if (data.Length >= 8)
{
Numerator = data[0];
Numerator |= (data[1] >> 8);
Numerator |= (data[2] >> 16);
Numerator |= (data[3] >> 24);
Denominator = data[4];
Denominator |= (data[5] >> 8);
Denominator |= (data[6] >> 16);
Denominator |= (data[7] >> 24);
}
}
 
|= is a logical OR with assignment. The VB equivalent would be "variable =
variable Or othervariable"

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Our Instant VB C# to VB.NET converter (free demo at www.instantvb.com)
produces the following:

'INSTANT VB WARNING: The following constructor is declared outside of its
associated class:
Public Sub New(ByVal data As Byte())
Denominator = 0
Numerator = 0
If data.Length >= 8 Then
Numerator = data(0)
Numerator = Numerator Or (data(1) >> 8)
Numerator = Numerator Or (data(2) >> 16)
Numerator = Numerator Or (data(3) >> 24)
Denominator = data(4)
Denominator = Denominator Or (data(5) >> 8)
Denominator = Denominator Or (data(6) >> 16)
Denominator = Denominator Or (data(7) >> 24)
End If
End Sub

--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
 
Smoke said:
I have found another small code from C# that i cannot convert.
My goal is to convert an existing EXIF metadata reader that is on C# to VB.net ... maybe someone already know of one made for VB.net
and can solve my problem..?

Besides, here is the code, i have no idea what |= is in VB.net

public EXIFRational(byte[] data)
{
Denominator = 0;
Numerator = 0;
if (data.Length >= 8)
{
Numerator = data[0];
Numerator |= (data[1] >> 8);
Numerator |= (data[2] >> 16);
Numerator |= (data[3] >> 24);

Apart from other replies, I think I should say that this code looks
extremely wrong. It looks like it's rebuilding Int32's from Bytes: but
if that is the intention, surely these shift operators should be << and
not >> ? For example, data[1] is a Byte; rightshifting it 8 times is
going to produce zero, always.

Anyone else?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top