Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert system type (C sharp) to java lang class

Tags:

java

c#

xamarin

I am trying to use Java library inside Xamarin project through binding. I need to pass a C sharp class type as a parameter to a Java method.

typeof() method in C sharp doesn't work because the compiler compilations

Cannot implicitly convert type "System.Type" to "Java.Lang.Class"

Is there any way to convert it correctly?

like image 845
caviar Avatar asked Aug 31 '15 09:08

caviar


1 Answers

Try to use Java.Lang.Class.FromType(Type) in Xamarin.

For example, your C sharp class could be Car

then call it as Java.Lang.Class.FromType(typeof(Car)) in Xamarin

like image 198
ding Avatar answered Nov 06 '22 20:11

ding