Join Ted Neward for an in-depth discussion in this video Accessing properties demo, part of CLR Reflection for Developers.
- [Instructor] So again, we constructed a point object,…and what we'd like to do is we'd like to access the X…or Y property of this object.…So again, if we're going to do this reflectively,…because again, remember, this in fact…is cast as a type object.…We are assuming, by definition,…that we do not know that this is a point ahead of time.…In that particular case, what we need to do…is we need to get ahold of the X and Y properties,…and again, we do that by going to the type,…and we say GetProperty, and we will specifically ask it…for the X property.…
Now again, by virtue of the fact…that X and Y are public properties,…we don't need the binding flags…because that in fact is the default,…so we can do the same thing for both X and Y property here,…like so.…Now, once we've got these properties,…if I choose to look at the value,…we can do so by simply asking the X property for the value.…
Notice the GetValue call here,…and notice the object that I pass in,…this case, we'll have it be the point.…That, in this particular case, since we know…
- Working with the IL Disassembler (Ildasm)
- Namespaces and types
- Type API
- Properties API
- MethodBase and MethodInfo API
- Constructors API
- Fields API
- Constructing objects
- Accessing properties and fields
- Invoking methods
Skill Level Intermediate
Deploying .NET Applications with Octopus Deploywith Floyd Hilton1h 27m Intermediate
2. IL Disassembler (Ildasm)
3. Reflection Namespace and Types
4. Type API
5. Properties API
6. MethodBase and MethodInfo API
7. Constructors API
Constructors API demo2m 52s
8. Fields API
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.