0

Does structs in c# have a fixed size? So thats why the following code :

struct Person
{
    Person child;
}

Will cause infinite cycling problems? Or because struct types contain their proper value and not a reference?

4
  • 3
    type definition != object reference. You are mixing things up here. Commented Nov 1, 2013 at 13:45
  • 4
    stackoverflow.com/a/9296289/961113 Commented Nov 1, 2013 at 13:46
  • 2
    "Will cause infinite cycling problems?" No, it wouldn't, because it will not compile. Commented Nov 1, 2013 at 13:47
  • But yes, indeed. This is not going to compile. Commented Nov 1, 2013 at 13:47

1 Answer 1

5

Yes, structs in C# are value types, containing the actual data directly. Classes are reference types, like pointers in other languages, containing only a reference to the actual object.

(See the link posted in comments which gives a detailed explanation of the issue)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.