DllImport采用通用方法 [英] DllImport with generic methods

查看:116
本文介绍了DllImport采用通用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我的问题是我想使用DllImport和泛型方法,我无法让它工作。我正在使用名为"newtonsoft.json">的C#库。我想用这种方法使用DllImport:

 

[DllImport(@"我的dll的路径")]
public static T DeserializeObject< T>(字符串值);

它给我一个错误。


我一直在搜索互联网,但我不能让它工作。我还想提一下,我是C#的初学程序员。感谢您的回复。



解决方案

您好,



 使用支持的库,JsonConverter< T>上课,这是一个链接;


 


  https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonConverter_1.htm


 


 请记住,使用第三方库时,他们的支持最有可能是


<比MSDN更多的帮助。


 


 希望这会有所帮助:)


Hello, my question is that i want to use DllImport with a generic method and i can't get it to work. I'm using a C# library called "newtonsoft.json"> I want to use DllImport with this method:

[DllImport(@"path to my dll")] public static T DeserializeObject<T>(string value);

It gives me a error.

I've been seraching the internet but i can't get it to work. I also want to mention that i'm a beginner programmer in C#. Thanks for every reply.

解决方案

Hello,

 Use the supported library, JsonConverter<T> Class, here is a link;

 

 https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonConverter_1.htm

 

 Remember, when using 3rd party library that their support is most likely to be of

more help than here at MSDN.

 

 Hope this helps :)


这篇关于DllImport采用通用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆