Thursday, June 25, 2009

Converting code between VB.NET and C# using SharpDevelop

While I really love the online VB.NET to C# and C# to VB.NET code converters provided by developerFusion, I have also found the open source SharpDevelop application to be a very good tool for converting .NET code from one flavor to another. It is especially good at converting whole projects or larger amounts of code. I think it is worthy a post:

http://www.icsharpcode.net/OpenSource/SD/

Code Conversion Features:

http://community.sharpdevelop.net/blogs/mattward/articles/FeatureTourCodeConversion.aspx

Code Conversion is one very small part of SharpDevelop. The rest is worth a look too!

Friday, June 5, 2009

Converting a Byte Array to a String in VB.NET

Here is one way to convert a byte array to a String in VB.NET:


Dim bArray() As Byte = {65, 66, 67, 68, 69}
Dim str As String
str = System.Text.Encoding.ASCII.GetString(bArray)



More examples of converting Byte Arrays to Strings and vice versa in VB.NET and C# can be found here:

http://www.chilkatsoft.com/faq/DotNetStrToBytes.html

Getting Application Path for a Console App

In a previous post, I gave examples of getting the Application Path for a Windows Form app and a Windows Mobile app. Getting the Application Path for a Console app is similar to getting one for the Windows Mobile app:


Dim appPath As String = _
System.IO.Path.GetDirectoryName( _
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)