问题描述
将项目1中的动态值传递给项目2中的方法,例如:var temp = new {d1 = 1,d2 = 2,d3 = 3};
传输对于项目2中的方法,使用temp :public static bool Ex(动态p),在项目2中,结果p {d1 = 1,d2 = 2,d3 = 3},但p.d1将失败。
帮助我!
我尝试过:
项目1:
var temp = new {d1 = 1,d2 = 2,d3 = 3};
Project2.Ex(在项目2中
公共静态布尔Ex(动态p)
>
结果p {d1 = 1,d2 = 2,d3 = 3},但p.d1。 。 。会失败吗?
}
Pass a dynamic value in project 1 to the method in project 2, for example: var temp = new {d1 = 1, d2 = 2, d3 = 3};
Transmit temp for method in project 2: public static bool Ex(dynamic p), in project 2, result p {d1 = 1, d2 = 2, d3 = 3}, but p.d1 will fail.
help me!
What I have tried:
Project 1:
var temp = new {d1=1,d2=2,d3=3};
Project2.Ex(temp).
In Project 2:
public static bool Ex(dynamic p)
{
Result p {d1=1,d2=2,d3=3}, but p.d1 . . . will fail?
}
推荐答案
internal static bool Ex(dynamic p) // make it as internal
$项目1中的b $ b
AssemblyInfo.cs
in project 1 AssemblyInfo.cs
[assembly:InternalsVisibleTo("Project2DLLName")]
项目2中的
AssemblyInfo.cs
in project 2 AssemblyInfo.cs
[assembly:InternalsVisibleTo("Project1DLLName")]
这篇关于在C#中的2个项目之间传递动态值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!