Join Ted Neward for an in-depth discussion in this video Accessing fields demo, part of CLR Reflection for Developers.
- [Instructor] All right, so again we've got our point here.…We've got a couple of objects that we can work with.…And in particular, the first thing I want to do is…I want to get a hold of the field…out of the point type.…So again, we just call "GetField".…Now, the key thing here is that…if I'm going to access the field,…I have to know the exact field name.…And remember, that's going to be that…compiler generated "<X>k__BindingField"),…or "BackingField" that's right.…
That's what it was called.…You're going to have to get the field name…exactly correct because if you don't,…then we're actually going to get "null" back,…and that will generate a null reference exception.…And let's make sure that we actually…got a hold of this thing by saying…"x backing field" is currently set to whatever…particular value.…And again, we can say "xField.GetValue" and we pass…in an instance here, in which case…we'll use our original point.…Now by virtue of the fact that…we set it through the property,…that should be 24 like so.…
And before we go much further, let's run this…
- 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.