我有一个看起来像这样的代码
if( evento.ObjetosUnity != null ) lista_elementos.AddRange( evento.ObjetosUnity.Cast<Elemento3DJS>() );
if( evento.Imagenes3D != null ) lista_elementos.AddRange( evento.Imagenes3D.Cast<Elemento3DJS>() );
if( evento.Botones != null ) lista_elementos.AddRange( evento.Botones.Cast<Elemento3DJS>() );
...and so on...
我必须遍历对象的所有字段.有没有更简单的方法可以做到这一点?
编辑:我正在将一个应用程序编译为iOS,并且不能使用Reflection.
Reflection.Emit
).docs.xamarin.com/guides/ios/advanced_topics/limitations/…简短的答案是"否".
没有反思,您将不得不阐明.是否要使用所有字段?为此编写代码.
I have a code that looks like this
if( evento.ObjetosUnity != null ) lista_elementos.AddRange( evento.ObjetosUnity.Cast<Elemento3DJS>() );
if( evento.Imagenes3D != null ) lista_elementos.AddRange( evento.Imagenes3D.Cast<Elemento3DJS>() );
if( evento.Botones != null ) lista_elementos.AddRange( evento.Botones.Cast<Elemento3DJS>() );
...and so on...
where I have to go through all the fields of an object. Is there an easier way of doing this?
Edit: I am compiling an App to iOS and CANT use Reflection.
Reflection.Emit
). docs.xamarin.com/guides/ios/advanced_topics/limitations/…The short answer is No.
Without reflection, you will have to spell it out. Want to use all fields? Write the code for it.
本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文