[英]how to convert system type (C sharp) to java lang class
I am trying to use Java library inside Xamarin project through binding . 我试图通过绑定在Xamarin项目中使用Java库。 I need to pass a C sharp class type as a parameter to a Java method.
我需要将C sharp类类型作为参数传递给Java方法。
typeof()
method in C sharp doesn't work because the compiler compilations C sharp中的
typeof()
方法不起作用,因为编译器编译
Cannot implicitly convert type "System.Type" to "Java.Lang.Class"
无法将类型“System.Type”隐式转换为“Java.Lang.Class”
Is there any way to convert it correctly? 有没有办法正确转换它?
Try to use Java.Lang.Class.FromType(Type)
in Xamarin. 尝试在Xamarin中使用
Java.Lang.Class.FromType(Type)
。
For example, your C sharp class could be Car
例如,你的C sharp类可能是
Car
then call it as Java.Lang.Class.FromType(typeof(Car))
in Xamarin 然后在Xamarin
Java.Lang.Class.FromType(typeof(Car))
其称为Java.Lang.Class.FromType(typeof(Car))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.