|
The functions of Microsoft Visual Basic still belong to it
and they can be called transparently in a Visual Basic application. If you want
to use them in a non-Visual Basic application, you must remember to reference
its library. Most (if not all) of the functions of Visual Basic are created in
the Microsoft.VisualBasic.dll assembly but they might be in different namespaces.
Based on this, you can include any Visual Basic function in your program. Here
is an example:
| Source File: Exercise.cs |
using System;
class Exercise
{
static void Main()
{
double Number;
double Result;
Console.Write("Enter a number: ");
string strNbr = Console.ReadLine();
if( !Microsoft.VisualBasic.Information.IsNumeric(strNbr) )
Number = 0.00;
else
Number = Microsoft.VisualBasic.Conversion.Val(strNbr);
Result = Number * 2;
Console.WriteLine("{0} * 2 = {1}", Number, Result);
}
}
|
When
compiling the program, you must reference the Microsoft.VisualBasic.dll library.
Here is an example:
csc /reference:Microsoft.VisualBasic.dll Exercise.cs
|
|