Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Use C# code from TCC

Aug
2,059
83
Here's how I access functions written in C# from TCC, using the new PSHELL and @PSHELL in TCC 21.

First, create a file with your C# code, in this example, TCCPS1.cs;
Code:
public class MathClass
{
   public static long Multiply(long x, long y)
   {
       return x * y;
   }

   public static long Add(long i, long j)
   {
       return i + j;
   }
}
Next, load this class into memory;
Code:
pshell /s "add-type -path c:\utils\tccps1.cs"
Use one of the functions from the class;
Code:
pshell /s "[MathClass]::Add(652,4)"
With the class loaded into memory, you can also use the @PSHELL function;
Code:
echo %@pshell[[MathClass]::Add(652,4)]
...or...
Code:
[c:\utils]set MathAdd=%@pshell[[MathClass]::Add(652,4)]

[c:\utils]echo %MathAdd
656

You can also use VB Code from TCC, in this example, TCCPS1.vb;
Code:
Public Class MathClass
  Public Shared Function Multiply(ByVal x As Long, ByVal y As Long) As Long
    Return x * y
  End Function

  Public Shared Function Add(ByVal i As Long, ByVal j As Long) As Long
    Return i + j
  End Function

End Class

Joe
 
Back
Top
[FOX] Ultimate Translator
Translate