PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Convert Java to C#

Reply

Convert Java to C#

 
Thread Tools Rate Thread
Old 06-03-2007, 05:29 PM   #1
=?Utf-8?B?amVmZg==?=
Guest
 
Posts: n/a
Default Convert Java to C#


Hi Guys,

I have a bunch of Java code, and want to convert them to C# code?

esp:

this code:

Java:
private const byte[] map2 = new byte[128];
static
{
for (int i=0; i<map2.length; i++) map2[i] = -1;
for (int i=0; i<64; i++) map2[map1[i]] = (byte)i;
}
To C#
???
???

how to convert it into initlize the const arry?
Sorry my first C# program?

Thanks.



  Reply With Quote
Old 06-03-2007, 05:49 PM   #2
Neil Cowburn
Guest
 
Posts: n/a
Default Re: Convert Java to C#

private const byte[] map2 = new byte[128];

static void MyMethod() {
for (int i=0; i<map2.Length; i++) map2[i] = -1;
for (int i=0; i<64; i++) map2[map1[i]] = (byte)i;
}

That ought to do it.

--
Neil Cowburn
Principal Partner
OpenNETCF Consulting, LLC.

Managed Code in the Embedded World

http://www.opennetcf.com/
http://www.smartdeviceframework.com/


"jeff" <jeff@discussions.microsoft.com> wrote in message
news:B3977A91-2625-481B-87D4-C2EEF4214C4F@microsoft.com...
> Hi Guys,
>
> I have a bunch of Java code, and want to convert them to C# code?
>
> esp:
>
> this code:
>
> Java:
> private const byte[] map2 = new byte[128];
> static
> {
> for (int i=0; i<map2.length; i++) map2[i] = -1;
> for (int i=0; i<64; i++) map2[map1[i]] = (byte)i;
> }
> To C#
> ???
> ???
>
> how to convert it into initlize the const arry?
> Sorry my first C# program?
>
> Thanks.
>
>
>


  Reply With Quote
Old 06-03-2007, 06:32 PM   #3
Nino Benvenuti
Guest
 
Posts: n/a
Default Re: Convert Java to C#

You may find some success with the Java Language Conversion Assistant:
http://msdn2.microsoft.com/en-us/vstudio/aa718346.aspx

--
Nino Benvenuti
Device Application Development MVP
http://nino.net/blog


"jeff" <jeff@discussions.microsoft.com> wrote in message
news:B3977A91-2625-481B-87D4-C2EEF4214C4F@microsoft.com...
> Hi Guys,
>
> I have a bunch of Java code, and want to convert them to C# code?
>
> esp:
>
> this code:
>
> Java:
> private const byte[] map2 = new byte[128];
> static
> {
> for (int i=0; i<map2.length; i++) map2[i] = -1;
> for (int i=0; i<64; i++) map2[map1[i]] = (byte)i;
> }
> To C#
> ???
> ???
>
> how to convert it into initlize the const arry?
> Sorry my first C# program?
>
> Thanks.
>
>
>


  Reply With Quote
Old 06-03-2007, 06:44 PM   #4
Guest
 
Posts: n/a
Default Re: Convert Java to C#

I think a static class ctor is where the init stuff should be.


--
Chris Tacke - Embedded MVP
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--



"jeff" <jeff@discussions.microsoft.com> wrote in message
news:B3977A91-2625-481B-87D4-C2EEF4214C4F@microsoft.com...
> Hi Guys,
>
> I have a bunch of Java code, and want to convert them to C# code?
>
> esp:
>
> this code:
>
> Java:
> private const byte[] map2 = new byte[128];
> static
> {
> for (int i=0; i<map2.length; i++) map2[i] = -1;
> for (int i=0; i<64; i++) map2[map1[i]] = (byte)i;
> }
> To C#
> ???
> ???
>
> how to convert it into initlize the const arry?
> Sorry my first C# program?
>
> Thanks.
>
>
>



  Reply With Quote
Old 06-03-2007, 07:16 PM   #5
=?Utf-8?B?amVmZg==?=
Guest
 
Posts: n/a
Default RE: Convert Java to C#

Thanks Guys,

I made it according you guys idea.



"jeff" wrote:

> Hi Guys,
>
> I have a bunch of Java code, and want to convert them to C# code?
>
> esp:
>
> this code:
>
> Java:
> private const byte[] map2 = new byte[128];
> static
> {
> for (int i=0; i<map2.length; i++) map2[i] = -1;
> for (int i=0; i<64; i++) map2[map1[i]] = (byte)i;
> }
> To C#
> ???
> ???
>
> how to convert it into initlize the const arry?
> Sorry my first C# program?
>
> Thanks.
>
>
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off