Similar to a class in C#, a struct is also a data structure that consists of members, functions, and so on. Classes are reference types, but structs are value types; hence, these are not required for heap allocation but for allocation on the stack.
Value type data will be allocated on stack and reference type data will be allocated on heap. A value type that is used in struct is stored on the stack, but when the same value type is used in an array, it is stored in a heap.
So, when ...