Question : Using C# code with VB.Net

Hi Experts,

If I have the attached C# code and wish to use it in my VB.Net project how would I go about doing this?

Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
public static double CelsiusToFahrenheit 
   (string temperatureCelsius)
{
   double celsius = System.Double.Parse (temperatureCelsius);
   return (celsius * 9 / 5) + 32; 
}
 
public static double FahrenheitToCelsius 
   (string temperatureFahrenheit)
{
   double fahrenheit = System.Double.Parse (temperatureFahrenheit);
   return (fahrenheit - 32) * 5 / 9;
}

Answer : Using C# code with VB.Net

First of all build a C# DLL using the methods described in the following link

http://www.c-sharpcorner.com/uploadfile/mahesh/dll12222005064058am/dll.aspx

Add the two methods in your DLL.

Now in your VB project, import the C# DLL which you created and call the appropriate method.

http://www.christec.co.nz/blog/archives/290
Random Solutions  
 
programming4us programming4us