dotnet indexed property access via propertyinfo getvalues 
Author Message
 dotnet indexed property access via propertyinfo getvalues

"dotnet indexed property access via propertyinfo getvalues"

Consider the code fragment from below...

<snip>

Dim prop As System.Reflection.PropertyInfo =
x.GetType.GetProperty("TestIndexer")

prop.SetValue(x, 333, Nothing)

</snip>

SetValue (obj As Object, value as Object, index() As Object)

index: Optional index values for indexed properties.  This value should be
null for non-indexed properties.

A few questions:

1)         As of yet, I have not seen "index() As Object" used in any VB.NET
samples.   All that I have ever seen is "null" or "Nothing" being used (even
for indexed property examples).  Is it "required" for programmatic access of
indexed properties?

2)         If not, what is the proper method of accessing indexed
properties?

3)         What would the SetValue call look like in C#?

[VB Sample class]

Public Class Class1

Private m_myArray(5) As Integer

Default Property TestIndexer(ByVal index As Integer, ByVal myInt As Integer)
As Integer

                Get

                    TestIndexer = m_myArray(index) + myInt

                End Get

                Set(ByVal Value As Integer)

                    m_myArray(index) = Value + myInt

                End Set

           End Property

End Class

[WebForm]

Dim prop As System.Reflection.PropertyInfo =
x.GetType.GetProperty("TestIndexer")

prop.SetValue(x, 333, Nothing)    '    What would an "index() As Object"
call look like here?

If I can find a way to do this in VB.NET, then I can port it to C#...of
which is what I need.



Sun, 03 Jul 2005 12:12:21 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. How Do I Access Hotmail (Mail) Via VB dotNet

2. VB2008: Getting the System.Reflection.PropertyInfo from within a class property

3. Accessing comix indexes via ADO

4. New To VB6 - accessing records via their indexes

5. Adding Field to Access db - need to make indexed property of field No Duplicates

6. Control Properties on Access forms via DAO

7. how do I access project properties (values) via VBA

8. Accessing Control Properties Via its Handle

9. accessing the properties of an embedded mscal object via VBA

10. How to set the required property in access databases via adox

11. Accessing properties via a DLL

12. Enum.GetValues() --> Invalid Cast

 

 
Powered by phpBB® Forum Software