Create a node called CSharp and attach a c# script to it. Put the following in the script.

using Godot;
using System;
using System.Runtime.InteropServices;

public class CSharp : Node
{
	[DllImport("testlib.dll", CallingConvention = CallingConvention.StdCall)]
	public static extern int add2i(int a, int b);
	
	[DllImport("testlib.dll", CallingConvention = CallingConvention.StdCall)]
	[return: MarshalAs(UnmanagedType.BStr)]
	public static extern string joinStrings([MarshalAs(UnmanagedType.LPWStr)] string a, [MarshalAs(UnmanagedType.LPWStr)] string b);
}

Attach a GDScript to your root node and put the following in to it.

extends Control

func _ready():
	var cs_node = $CSharp
	print(cs_node.add2i(1, 2))
	print(cs_node.joinStrings("123", "456"))

You will obviously need a "testlib.dll" with the 2 functions inside it for it to work.
I use Purebasic to create my DLL's but you can use anything you like. You can also specify the calling convention and return types as well as parameter types

Have fun 🙂

    6 months later

    AndyG
    I got error below. can you show me how to fix?
    error while processing request 'variables' (exception: Object reference not set to an instance of an object.)
    Thanks