Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Again: Reflection and array´s...

Again: Reflection and array´s...

Scheduled Pinned Locked Moved C#
helptutorialquestiondata-structures
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Norman Timo
    wrote on last edited by
    #1

    Hello everybody! My problem is to get/set individual array items which are instanced via reflection. To give you an overwiew here´s some code: *************************************************** System.Reflection.Assembly assembly; assembly = System.Reflection.Assembly.LoadFrom(dllfilename); foreach(Type assemblyType in assembly.GetTypes()) { if (assemblyType.IsClass) objInstance = Activator.CreateInstance(viptype); foreach(FieldInfo f in objInstance.GetFields(BindingFlags.Public | BindingFlags.Instance)) { if (f.FieldType.IsArray) { // read every array value! // f.GetValue(objInstance) returns only a complete value (and I don´t know how to handle this) // How can I access to every array item itself??? } else { // do something different. This is working fine! } } } ************************************************* And the source from the assembly looks something like that (extremely shortened, but same structure): ************************ public class myClass { public int ID; // Test public int Test; // Array public int array[15]; } ************************ How can I get in the source at the top for example the 10th integer of the array? Please help me Norman-Timo

    N L 2 Replies Last reply
    0
    • N Norman Timo

      Hello everybody! My problem is to get/set individual array items which are instanced via reflection. To give you an overwiew here´s some code: *************************************************** System.Reflection.Assembly assembly; assembly = System.Reflection.Assembly.LoadFrom(dllfilename); foreach(Type assemblyType in assembly.GetTypes()) { if (assemblyType.IsClass) objInstance = Activator.CreateInstance(viptype); foreach(FieldInfo f in objInstance.GetFields(BindingFlags.Public | BindingFlags.Instance)) { if (f.FieldType.IsArray) { // read every array value! // f.GetValue(objInstance) returns only a complete value (and I don´t know how to handle this) // How can I access to every array item itself??? } else { // do something different. This is working fine! } } } ************************************************* And the source from the assembly looks something like that (extremely shortened, but same structure): ************************ public class myClass { public int ID; // Test public int Test; // Array public int array[15]; } ************************ How can I get in the source at the top for example the 10th integer of the array? Please help me Norman-Timo

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Norman-Timo wrote: How can I get in the source at the top for example the 10th integer of the array? It is reflecting against what was just loaded into memory, there will be no value in the 10th position of the array. - Nick Parker
      My Blog | My Articles

      1 Reply Last reply
      0
      • N Norman Timo

        Hello everybody! My problem is to get/set individual array items which are instanced via reflection. To give you an overwiew here´s some code: *************************************************** System.Reflection.Assembly assembly; assembly = System.Reflection.Assembly.LoadFrom(dllfilename); foreach(Type assemblyType in assembly.GetTypes()) { if (assemblyType.IsClass) objInstance = Activator.CreateInstance(viptype); foreach(FieldInfo f in objInstance.GetFields(BindingFlags.Public | BindingFlags.Instance)) { if (f.FieldType.IsArray) { // read every array value! // f.GetValue(objInstance) returns only a complete value (and I don´t know how to handle this) // How can I access to every array item itself??? } else { // do something different. This is working fine! } } } ************************************************* And the source from the assembly looks something like that (extremely shortened, but same structure): ************************ public class myClass { public int ID; // Test public int Test; // Array public int array[15]; } ************************ How can I get in the source at the top for example the 10th integer of the array? Please help me Norman-Timo

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        Use the methods as given in the Array base class, or access it via the "Item" property. top secret xacc-ide 0.0.1

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups