我的方法定义是
public ActionResult _Create3<T>() where T:IMyClass, new()
Run Code Online (Sandbox Code Playgroud)
但我想定义两种通用类型
public ActionResult _Create3<T, G>(G content) where T:IMyClass, new()
Run Code Online (Sandbox Code Playgroud)
G型也必须使用ImyClass接口,但我不知道在哪里定义两种类型!
例如,如果可能写:
public ActionResult _Create3<T, G>(G content) where {T:IMyClass, G:IMyClass}, new()
Run Code Online (Sandbox Code Playgroud)
但得到错误.
谢谢你的回答
我在dll中有一个类定义.我通过接口导出这个类.我在其他Delphi项目中使用这个dll和类非常好但是我想在c#中使用这个类但是为我发送错误.
源DLL:
type
IMyDate = interface
['{D032F796-167D-4B0D-851D-2AEEA226646A}']
Procedure Analyze_Date(var y:Integer; m,d:Integer); stdcall;
end;
TMyDate = Class(TInterfacedObject, IMyDate)
Public
Procedure Analyze_Date(var y:integer; m,d:Integer); stdcall;
End;
procedure TMyDate.Analyze_Date(var y:Integer; m, d: Integer);
begin
y:= m+d;
end;
Function MyDate:IMyDate; stdcall;
begin
result:= TMyDate.Create;
end;
exports
MyDate;
Run Code Online (Sandbox Code Playgroud)
Delphi中的单元使用示例:
Function MyDate:IMyDate; stdcall; external 'Project11';
implementation
procedure TForm3.Button1Click(Sender: TObject);
var
md:IMyDate;
var y,m,d:Integer;
begin
md:= MyDate;
y:=10;
m:=20;
d:=30;
md.Analyze_Date(y,m,d);
showMessage(intTostr(y));
end;
Run Code Online (Sandbox Code Playgroud)
在c#中使用但得到错误:
//[Guid("D032F796-167D-4B0D-851D-2AEEA226646A")]
public interface IMyDate
{
void Analyze_Date(ref int y, int m, int d); …Run Code Online (Sandbox Code Playgroud)