[英]Iterate through all fields of an object in C# without Reflection
我有一個看起來像這樣的代碼
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。
簡短的答案是“ 否” 。
沒有反思,您將不得不闡明。 是否要使用所有字段? 為此編寫代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.