Conversion tools (VB.NET to C#)
Page 1 of 114 Replies - 7155 Views - Last Post: 21 February 2018 - 06:50 AM
#1
Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 01:14 AM
Replies To: Conversion tools (VB.NET to C#)
#2
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 05:44 AM

#3
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 05:46 AM
Generally if you write good code in C#, then you should get good code back in VB.NET.
#4
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 08:54 AM
Quote

Well i haven't written in VB.NET for almost a year i forgot syntax a little.
#5
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 09:18 AM

#6
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 09:23 AM
http://www.harding.e...comparison.html
#7
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 09:31 AM
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
#8
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 11:33 AM
#9
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 11:48 AM
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
#10
Re: Conversion tools (VB.NET to C#)
Posted 23 October 2013 - 11:57 AM
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.
#11
Re: Conversion tools (VB.NET to C#)
Posted 24 October 2013 - 02:00 PM
#12
Re: Conversion tools (VB.NET to C#)
Posted 24 October 2013 - 02:04 PM
alapee, on 24 October 2013 - 09:00 PM, said:
If you read the original post, this is what the OP is currently using and asked about.
#13
Re: Conversion tools (VB.NET to C#)
Posted 24 October 2013 - 02:40 PM
andrewsw, on 24 October 2013 - 04:04 PM, said:
alapee, on 24 October 2013 - 09:00 PM, said:
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.
#14
Re: Conversion tools (VB.NET to C#)
Posted 24 October 2013 - 02:45 PM
andrewsw - thanks for keeping me honest, I just got so excited to share the news about Fusion, I completely skipped the first post.
#15
Re: Conversion tools (VB.NET to C#)
Posted 21 February 2018 - 06:50 AM