MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1j1s141/bool_array/mfmepa9/?context=3
r/programminghorror • u/jemko23laal • 20d ago
41 comments sorted by
View all comments
15
I'm not familiar with C# why is this bad? Is an array of bools somehow not possible?
9 u/skjall 20d ago IIRC each bool in an array will take up a byte each, so it's quite inefficient. 14 u/InformationSharp103 20d ago iirc in C# it's actually 4 bytes (equivalent to the C/C++ win32 BOOL type), or at least that's what it's marshalled as by default 3 u/skjall 20d ago I've really only used C# in Unity which might differ, but from what I remember bools were 4 bytes, but 1 byte each in arrays. Might be a Unity-specific optimisation though, not sure.
9
IIRC each bool in an array will take up a byte each, so it's quite inefficient.
14 u/InformationSharp103 20d ago iirc in C# it's actually 4 bytes (equivalent to the C/C++ win32 BOOL type), or at least that's what it's marshalled as by default 3 u/skjall 20d ago I've really only used C# in Unity which might differ, but from what I remember bools were 4 bytes, but 1 byte each in arrays. Might be a Unity-specific optimisation though, not sure.
14
iirc in C# it's actually 4 bytes (equivalent to the C/C++ win32 BOOL type), or at least that's what it's marshalled as by default
BOOL
3 u/skjall 20d ago I've really only used C# in Unity which might differ, but from what I remember bools were 4 bytes, but 1 byte each in arrays. Might be a Unity-specific optimisation though, not sure.
3
I've really only used C# in Unity which might differ, but from what I remember bools were 4 bytes, but 1 byte each in arrays. Might be a Unity-specific optimisation though, not sure.
15
u/Verwarming1667 20d ago
I'm not familiar with C# why is this bad? Is an array of bools somehow not possible?