Results 1 to 2 of 2

Thread: [2.0] Reflection question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    didn't decide yet
    Posts
    222

    [2.0] Reflection question

    please someone explain to me why the 3rd line of my code fails

    Code:
    TypeDescriptor.CreateProperty(typeof (Class1), "test", typeof (int));
    Assert.IsNotNull(TypeDescriptor.GetProperties(typeof (Class1).GetProperty("test")));
    Assert.IsNotNull(typeof (Class1).GetProperty("test"));
    Come and get our ISDN CallerID http://www.3wm.biz

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Reflection question

    I can't claim to have got that far into reflection but that first line does NOT create a property named "test". It creates a property descriptor for a property named "test". The second line doesn't fail because it simply returns an empty PropertyDescriptorCollection. The third line does fail because Class1 has no property named "test".
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width