mardi 6 octobre 2015

Java Reflection to ASP .Net MVC Reflection

The code below tells about the reflection in java. Now, I want this code to convert in C#. Can somebody tell me how to convert this in to C# code? I mean, I want to learn about reflection in ASP .Net MVC. Sad to say that I'm newbie to ASP .Net. :( but, I just wanna learn this thing. :) Your answers will be highly appreciated. Thank you so much.

private boolean set(Object object, String fieldName, Object fieldValue) {
      Class<?> clazz = object.getClass();
      while (clazz != null) {
          try {
              Field field = clazz.getDeclaredField(fieldName);
              field.setAccessible(true);
              field.set(object, fieldValue);
              return true;
          } catch (Exception e) {
              throw new IllegalStateException(e);
          }
      }
      return false;
  }





Aucun commentaire:

Enregistrer un commentaire