In the Samples supplied with Visual Cobol you find examples on how to call (native) Cobol code from C#. But, what about the other way 'round? Calling C# from Cobol? Enter this as a search and you find nothing. Maybe this will be of help to those of you, who are not aquainted to mixed language "calls". Looking into the Web you find thousands of examples of C# coding. Samples regarding XML, LINQ and whatsoever (see CodeProject i.e.). You can easily integrate these into your managed Cobol applications. All you need to do is set "using System.Runtime.InteropServices" in the C# code added to your solution. Of course the methods need to be public like: namespace myClass public class Class_myClass public string[] DoSomething() // the method. string arrays are an easy way to define return values // define the string array to return values string[] lst = new string[10]; // here 10 values // write the code and then return the values lst[0] = value1.ToString; lst[1] = value2.ToString; // and so on return lst; In your Cobol solution you need to make a reference to "myClass" (to be found in solution in the reference manager) * you can then define the callable class 01 Cclass type myClass.Class_myClass. 01 lst string[]. * the return values * In your method set Cclass to new myClass.Class_myClass invoke Cclass::DoSomething() returning lst that's all. I hope it will be of help.
↧