Because the Arithmetic class in this sample is a garbage-collected (managed) class, it can be used by any managed language. It's just a matter of adding the reference (by browsing to the file that holds the assembly) and using the class. Here's how to do it in a C# console application:
Some suitable testing code in C# follows : using System; namespace CSUseLibrary { /// <summary> /// Summary description for Class1. /// </summary> class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { ManagedMathLibrary.Arithmetic a = new ManagedMathLibrary.Arithmetic(); Console.Write("4.1 + 5.9 is "); Console.WriteLine(a.Add(4.1, 5.9)); Console.ReadLine(); } } } Some things to notice about C# in contrast to Managed C++:
This code compiles and runs with no further work on your part: Adding the reference takes care of everything. Binary compatibility, even across languages, is simple on the .NET runtime. It's just as simple from Visual Basic, assuming you're comfortable with the syntax. |