If you have declared a struct:
struct EmptyResult
{
}
What is the result of creating a variable of type EmptyResult
in an instance?
public Foo()
{
EmptyResult result;
}
Would you expect an allocation on the stack, or is it effectively a no-op?
A C# struct with no fields still has a size of 1. The reason this is so is that the compiler must be able to take the address of a struct using the &
operator in unsafe code.
I would expect your struct type to be treated exactly the same way as the byte
type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With