13 Replies - 1993 Views - Last Post: 24 October 2013 - 02:45 PM

#1 Michael26  Icon User is offline

  • DIC-head, major DIC-head
  • member icon

Reputation: 349
  • View blog
  • Posts: 1,498
  • Joined: 08-April 09

Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 01:14 AM

I've been using developer fusion tool for conversion(VB.NET to C#), but i don't know how accurate it is since VB.NET is "not my language" meaning i don't use VB.NET syntax very often, so i'm asking any VB.NET experts here to check if the converted code adheres to standards. I use this tool to help people in VB.NET forum.

Is This A Good Question/Topic? 0
  • +

Replies To: Conversion tools (VB.NET to C#)

#2 ybadragon  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 177
  • View blog
  • Posts: 1,091
  • Joined: 11-May 12

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 05:44 AM

Do you have some sample C# code we can use to test? I haven't written in C# in over a year :P
Was This Post Helpful? 0
  • +
  • -

#3 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 05:46 AM

What standards are we walking about here?

Generally if you write good code in C#, then you should get good code back in VB.NET.
Was This Post Helpful? 0
  • +
  • -

#4 Michael26  Icon User is offline

  • DIC-head, major DIC-head
  • member icon

Reputation: 349
  • View blog
  • Posts: 1,498
  • Joined: 08-April 09

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 08:54 AM

Quote

I haven't written in C# in over a year :P

Well i haven't written in VB.NET for almost a year i forgot syntax a little.
Was This Post Helpful? 0
  • +
  • -

#5 ybadragon  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 177
  • View blog
  • Posts: 1,091
  • Joined: 11-May 12

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 09:18 AM

That's why I asked for a C# sample, to compare it to the VB.NET the converter returns :)
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8907
  • View blog
  • Posts: 33,389
  • Joined: 12-June 08

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 09:23 AM

When in doubt - double check other sources (Telerik's great : http://converter.telerik.com/ ) or spot check by hand.

http://www.harding.e...comparison.html
Was This Post Helpful? 1
  • +
  • -

#7 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3178
  • View blog
  • Posts: 10,640
  • Joined: 12-December 12

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 09:31 AM

You could of course copy the resultant code into Visual Studio. If it is only a few statements then you could run them in LINQPad.

No converter could do a better job than the programmer sitting in front of the screen :)

This post has been edited by andrewsw: 23 October 2013 - 09:33 AM

Was This Post Helpful? 1
  • +
  • -

#8 Michael26  Icon User is offline

  • DIC-head, major DIC-head
  • member icon

Reputation: 349
  • View blog
  • Posts: 1,498
  • Joined: 08-April 09

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 11:33 AM

Alright thanks everybody. I wasn't talking about exact example, so no code sample provided, i will use VS and telerik whenever i can i study vb.net syntax some more.
Was This Post Helpful? 0
  • +
  • -

#9 Rhino1111  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 96
  • View blog
  • Posts: 220
  • Joined: 28-August 13

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 11:48 AM

I grabbed some random VB.Net code out of the VB.Net section and put it into the converter.

It turned this VB code:

Sub InputData(number As Double, factor As Double)
        If IsNumeric(txtNumber.Text) Then
            number = CDbl(txtNumber.Text)
            If number > 1 Then
                Do Until number = 1
                    For factor = 2 To number
                        If number Mod factor = 0 Then
                            lstResults.Items.Add(factor)
                        End If
                    Next
                Loop
            Else
                MessageBox.Show("Number must be greater than 1", "Input error")
            End If
        Else
            MessageBox.Show("Must enter a numeric value", "Input error")
        End If
    End Sub





Into this C# code...


public void InputData(double number, double factor)
{
	if (Information.IsNumeric(txtNumber.Text)) {
		number = Convert.ToDouble(txtNumber.Text);
		if (number > 1) {
			while (!(number == 1)) {
				for (factor = 2; factor <= number; factor++) {
					if (number % factor == 0) {
						lstResults.Items.Add(factor);
					}
				}
			}
		} else {
			MessageBox.Show("Number must be greater than 1", "Input error");
		}
	} else {
		MessageBox.Show("Must enter a numeric value", "Input error");
	}
}



From a quick glance the conversion seems completely fine. The formatting is a bit ugly, but that's just personal preference.

This post has been edited by Rhino1111: 23 October 2013 - 11:50 AM

Was This Post Helpful? 0
  • +
  • -

#10 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Conversion tools (VB.NET to C#)

Posted 23 October 2013 - 11:57 AM

With that kind of stuff generally the results are going to be fine as there aren't many places the generator can screw up in (without completely changing the logic in the code).

It's just like how various reflector tools can split out VB or C# given some MSIL file. With the basic concepts like methods, loops etc etc they can generate good code in either. It would be more interesting to see how they cope when you starting adding in language specific features - and see how badly they freak out.
Was This Post Helpful? 0
  • +
  • -

#11 alapee  Icon User is offline

  • The North American Snipe

Reputation: 94
  • View blog
  • Posts: 1,607
  • Joined: 24-October 13

Re: Conversion tools (VB.NET to C#)

Posted 24 October 2013 - 02:00 PM

I use Developer Fusion When I have to Convert Back and forth. I like it has pulled me out some of jams when I couldn't find VB Code and found solutions in C#.
Was This Post Helpful? 0
  • +
  • -

#12 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3178
  • View blog
  • Posts: 10,640
  • Joined: 12-December 12

Re: Conversion tools (VB.NET to C#)

Posted 24 October 2013 - 02:04 PM

View Postalapee, on 24 October 2013 - 09:00 PM, said:

I use Developer Fusion When I have to Convert Back and forth. I like it has pulled me out some of jams when I couldn't find VB Code and found solutions in C#.

If you read the original post, this is what the OP is currently using and asked about.
Was This Post Helpful? 0
  • +
  • -

#13 alapee  Icon User is offline

  • The North American Snipe

Reputation: 94
  • View blog
  • Posts: 1,607
  • Joined: 24-October 13

Re: Conversion tools (VB.NET to C#)

Posted 24 October 2013 - 02:40 PM

View Postandrewsw, on 24 October 2013 - 04:04 PM, said:

View Postalapee, on 24 October 2013 - 09:00 PM, said:

I use Developer Fusion When I have to Convert Back and forth. I like it has pulled me out some of jams when I couldn't find VB Code and found solutions in C#.

If you read the original post, this is what the OP is currently using and asked about.


Son of Gun , I apologize. I don't know how I skipped that. Now I have to go reread those first posts again.
Was This Post Helpful? 0
  • +
  • -

#14 alapee  Icon User is offline

  • The North American Snipe

Reputation: 94
  • View blog
  • Posts: 1,607
  • Joined: 24-October 13

Re: Conversion tools (VB.NET to C#)

Posted 24 October 2013 - 02:45 PM

After Kicking my Self well. Micheal26- I have been using Fusion now for 2 months and only have ran into 2 issues with the code conversion. Both were easily resolved with importing the correct classes and adding the correct references, but this was on the C# to Vb.net conversion. I have yet to work with the opposite way.

andrewsw - thanks for keeping me honest, I just got so excited to share the news about Fusion, I completely skipped the first post.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1