getproperties and order of properties 
Author Message
 getproperties and order of properties

Hi all

I have a class comtaining 5 properties :

public class test

Property1.....
Property2.....
Property3.....
Property4.....
Property5.....

end class

I create an object of my test class

objTest = new test()

Then I do this :

Dim properties As System.Reflection.PropertyInfo()
Dim akt_property As System.Reflection.PropertyInfo

properties = objTest .GetType.GetProperties

      For i = 0 To properties.Length - 1
        akt_property = properties(i)

        Debug.WriteLine("property : " & akt_property.Name)
      Next

What I would expect to get was an ordered list of the names of the 5
properties, but what I get is this :

Property4
Property1
Property3
Property5
Property2

It seems like reflection runs through the properties in a totaly unordered
way.

Why is this, and is there any way to get around it to get an orderen list ??

Thanks in advance

Allan



Sat, 29 Jan 2005 19:53:42 GMT  
 getproperties and order of properties

I tired out the example that you have given with 3 properties. But I got the output in an ordered format, like you want it.

I tried two cases.

In the first case I declared the properties in the following sequence:
P1
P2
P3

In the second case I declared the properties in the following sequence:
P1
P3
P2

In both the cases I got the output as follows:
property : P1
property : P2
property : P3

Regards, Rahul.

  Hi all

  I have a class comtaining 5 properties :

  public class test

  Property1.....
  Property2.....
  Property3.....
  Property4.....
  Property5.....

  end class

  I create an object of my test class

  objTest = new test()

  Then I do this :

  Dim properties As System.Reflection.PropertyInfo()
  Dim akt_property As System.Reflection.PropertyInfo

  properties = objTest .GetType.GetProperties

        For i = 0 To properties.Length - 1
          akt_property = properties(i)

          Debug.WriteLine("property : " & akt_property.Name)
        Next

  What I would expect to get was an ordered list of the names of the 5
  properties, but what I get is this :

  Property4
  Property1
  Property3
  Property5
  Property2

  It seems like reflection runs through the properties in a totaly unordered
  way.

  Why is this, and is there any way to get around it to get an orderen list ??

  Thanks in advance

  Allan



Sat, 29 Jan 2005 20:39:34 GMT  
 getproperties and order of properties

I must admit that this was a simple example of what I'm really doing, since the real thing would be much to complicated to explain my problem.

But in the real code the order is out of order.

Allan


  I tired out the example that you have given with 3 properties. But I got the output in an ordered format, like you want it.

  I tried two cases.

  In the first case I declared the properties in the following sequence:
  P1
  P2
  P3

  In the second case I declared the properties in the following sequence:
  P1
  P3
  P2

  In both the cases I got the output as follows:
  property : P1
  property : P2
  property : P3

  Regards, Rahul.

    Hi all

    I have a class comtaining 5 properties :

    public class test

    Property1.....
    Property2.....
    Property3.....
    Property4.....
    Property5.....

    end class

    I create an object of my test class

    objTest = new test()

    Then I do this :

    Dim properties As System.Reflection.PropertyInfo()
    Dim akt_property As System.Reflection.PropertyInfo

    properties = objTest .GetType.GetProperties

          For i = 0 To properties.Length - 1
            akt_property = properties(i)

            Debug.WriteLine("property : " & akt_property.Name)
          Next

    What I would expect to get was an ordered list of the names of the 5
    properties, but what I get is this :

    Property4
    Property1
    Property3
    Property5
    Property2

    It seems like reflection runs through the properties in a totaly unordered
    way.

    Why is this, and is there any way to get around it to get an orderen list ??

    Thanks in advance

    Allan



Sun, 30 Jan 2005 15:07:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. MSChat oxc csMember.GetProperties() Problem

2. Reading the Z-order property

3. tab order in property sheets

4. populating order number field affects unrelated orders!

5. Help in finding High Order and Low Order Words

6. Listbox order click order

7. dictionary objects: key in order = sequential out order?

8. Sorting numbers in Descending Order using ORDER BY

9. HELP! with Ordered Listbox (Re-ordering)

10. Order By - or Original order ??

11. Sorting numbers in Descending Order using ORDER BY

12. Combining tab order with tab order of a child form

 

 
Powered by phpBB® Forum Software