Click here to Skip to main content
15,889,266 members
Home / Discussions / C#
   

C#

 
GeneralPropertyGrid Pin
blankg2-Aug-04 2:03
blankg2-Aug-04 2:03 
GeneralRe: PropertyGrid Pin
Nick Parker2-Aug-04 3:35
protectorNick Parker2-Aug-04 3:35 
GeneralXml Serialization and Interfaces... Pin
mgaerber2-Aug-04 1:00
mgaerber2-Aug-04 1:00 
GeneralRe: Xml Serialization and Interfaces... Pin
leppie2-Aug-04 1:03
leppie2-Aug-04 1:03 
GeneralRe: Xml Serialization and Interfaces... Pin
mgaerber2-Aug-04 1:36
mgaerber2-Aug-04 1:36 
GeneralRe: Xml Serialization and Interfaces... Pin
leppie2-Aug-04 4:13
leppie2-Aug-04 4:13 
GeneralRe: Xml Serialization and Interfaces... Pin
mgaerber12-Aug-04 23:10
mgaerber12-Aug-04 23:10 
GeneralReflection and array´s... Pin
Norman-Timo2-Aug-04 0:43
Norman-Timo2-Aug-04 0:43 
And here I´m again...

I have problems to get a specified Array Length from an assembly file.

First here is a extract from the assembly file (source):

public class SEGMENT_FLATNESS
{
public int ID { get{ return 221; } }

// date as 8-digit integer in format yyyymmdd
public int DATE;
// time as 6-digit integer in format hhmmss
public int TIME;
// test
public float[] FLATNESS;

public SEGMENT_FLATNESS ()
{
FLATNESS = new float[35];
}

}


To get the array length I tried following:
first I have ceated an instance from the upper class, then I got the related Field and tried to get the Property 'Length' from it.

The second way was to invoke the Method GetLength from the array, but both didn´t work.

Here my last try:

using System;

using System.Reflection;

namespace DummyTest
{
///
/// Summary description for Class1.
///

class Class1
{
///
/// The main entry point for the application.
///

[STAThread]
static void Main(string[] args)
{
Assembly testAss = System.Reflection.Assembly.LoadFrom("KorrektesFile");

Type testType = testAss.GetType("SEGMENT_FLATNESS");

object testInvoke = Activator.CreateInstance(testType);

FieldInfo testInfo = testType.GetField("FLATNESS");

Type fieldType = testInfo.FieldType; // weiß nicht ob das nötig ist

PropertyInfo p = fieldType.GetProperty("Length");

MethodInfo[] testMethodInfo = p.GetAccessors(false); //liefert nur die public get Methode für die Länge!!!

testMethodInfo[0].Invoke(testInvoke, null); // **************

string tmpString = testInfo.Name; //dummyZeile wg. debug (kein vorzeitiges Ende)
}
}
}


What did I wrong? And how can I get the array length?

Please help me...
Norman-Timo
GeneralRe: Reflection and array´s... Pin
leppie2-Aug-04 1:01
leppie2-Aug-04 1:01 
GeneralRe: Reflection and array´s... Pin
leppie2-Aug-04 1:08
leppie2-Aug-04 1:08 
GeneralRe: Reflection and array´s... Pin
Norman-Timo2-Aug-04 1:30
Norman-Timo2-Aug-04 1:30 
GeneralRe: Reflection and array´s... Pin
leppie2-Aug-04 4:14
leppie2-Aug-04 4:14 
GeneralRe: Reflection and array´s... Pin
Norman-Timo2-Aug-04 20:00
Norman-Timo2-Aug-04 20:00 
QuestionHow to decide Page Break insertion criteria in RTF doc? Pin
sachinkalse2-Aug-04 0:05
sachinkalse2-Aug-04 0:05 
Generalserialize an object for use by drag & drop Pin
misterbear1-Aug-04 23:15
misterbear1-Aug-04 23:15 
Questionglobal Variables?? Pin
JayJ1-Aug-04 22:37
JayJ1-Aug-04 22:37 
AnswerRe: global Variables?? Pin
El'Cachubrey1-Aug-04 23:13
El'Cachubrey1-Aug-04 23:13 
AnswerRe: global Variables?? Pin
sreejith ss nair1-Aug-04 23:18
sreejith ss nair1-Aug-04 23:18 
AnswerRe: global Variables?? Pin
ILoveCS1-Aug-04 23:22
ILoveCS1-Aug-04 23:22 
GeneralRe: global Variables?? Pin
Colin Angus Mackay1-Aug-04 23:55
Colin Angus Mackay1-Aug-04 23:55 
GeneralRe: global Variables?? Pin
misterbear2-Aug-04 0:17
misterbear2-Aug-04 0:17 
GeneralRe: global Variables?? Pin
Colin Angus Mackay2-Aug-04 0:34
Colin Angus Mackay2-Aug-04 0:34 
GeneralRESOLVED Pin
JayJ2-Aug-04 5:09
JayJ2-Aug-04 5:09 
GeneralRe: global Variables?? Pin
ILoveCS2-Aug-04 15:36
ILoveCS2-Aug-04 15:36 
GeneralRe: global Variables?? Pin
Colin Angus Mackay2-Aug-04 23:01
Colin Angus Mackay2-Aug-04 23:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.