运行截图
PYTHON 源码
import clr
clr.AddReference("libs/NetDll")
from NetDll import *
if __name__ == '__main__':
for i in range(0,10):
instance = Test()
data = instance.GetData()
#ts
print(data.ts)
#id
print(data.id)
C#源码
using System;
using System.Collections.Generic;
using System.Text;
namespace NetDll
{
public class Test
{
public static int index = 0;
public Data GetData()
{
Data data = new Data();
data.ts = DateTime.Now.Ticks.ToString();
data.id = ++index;
return data;
}
}
}
using System;
namespace NetDll
{
public class Data
{
public Data() { }
public string ts;
public int id;
}
}
案例Demo下载
Python 版本
3.x
Python库
pythonnet
安装
pip install pythonnet
安装 pythonnet 后 import clr库
如果本身装有 clr 请卸载 pip uninstall clr
然后 安装 pythonnet库 后再重新引入
C#
dll 框架 .NET Standard 2.0
Vistual 版本
vistual studio 2022