C# Programming - Structures - Discussion

Discussion Forum : Structures - General Questions (Q.No. 2)
2.
Creating empty structures is allowed in C#.NET.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
5 comments Page 1 of 1.

Durg said:   1 decade ago
struct s {} // is not this empty structure

class c
{
static void Main()
{
s s1;
}
}

Vishal said:   1 decade ago
struct Test
{
static void Main()
{

}
}

when I create this it execute successfully. Its also a type of empty structure.

Nicholas Mahbouby said:   1 decade ago
Creating an empty structure is allowed in C# and the compiler will not complain. However all structs implicitly inherit members from System.ValueType and thus are never really empty.

Andrew said:   1 decade ago
May be empty constructors?

Brian Andersen said:   1 year ago
var x = new int?[10]; is an empty array.
There weren't any reference to the keyword struct.

Also, one might interpret that a 'struct MyStruct {}' is empty.

Post your comments here:

Your comments will be displayed after verification.