I know that with Array Lists you can hold different types. Can you acomplish the same thing with arrays for example an array containing both ints and strings?
iConqueror 27 Junior Poster
Recommended Answers
Jump to PostNo, an array is defined for one type.
But you could do the following:[StructLayout(LayoutKind.Explicit)] unsafe struct StringInt { [FieldOffset(0)] public fixed char name[30]; [FieldOffset(0)] public int MyInt; //[FieldOffset(21)] etc. //possible other types }
Do not forget to add:
using System.Runtime.InteropServices;
Now you could make …
All 3 Replies
ddanbe 2,724 Professional Procrastinator Featured Poster
iConqueror commented: cheers +2
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.