© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
19 replies
Tinister

Reflection with InlineArrayAttribute?

If I have an
object o
object o
that I know is a struct with
InlineArrayAttribute
InlineArrayAttribute
, how would I go about getting/setting each of the items?

I can get the length with
o.GetType().GetCustomAttribute<InlineArrayAttribute>()?.Length
o.GetType().GetCustomAttribute<InlineArrayAttribute>()?.Length


And I can get its field with
o.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Single()
o.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Single()


But using
fieldInfo.GetValue/fieldInfo.SetValue
fieldInfo.GetValue/fieldInfo.SetValue
seems to only get/set the item at index 0 in the array.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ System.Reflection
C#CC# / help
4y ago
reflection good course
C#CC# / help
2y ago
Casting, reflection or?
C#CC# / help
3y ago
❔ Reference counting, reflection
C#CC# / help
4y ago