<p>I get an error when I compile this code:</p>

<pre><code>using System;

public struct Vector2
{
    public event EventHandler trigger;

    public float X;
    public float Y;

    public Vector2 func()
    {
        Vector2 vector;
        vector.X = 1;
        vector.Y = 2;
        return vector;  // error CS0165: Use of unassigned local variable 'vector'
    }
}
</code></pre>

<p>hi!</p>

<p>The compiler says: "Use of unassigned local variable 'vector'" and points to the return value. It looks to me that Vector2 become a reference type (without the event member it acts normally). What is happening?</p>

In C# you still need to 'new' a struct to call a constructor unless you are initializing
all
the fields.  You left EventHandler member 'trigger' unassigned.
Try either assigning to 'trigger' or using:
```
```
Vector2 vector = new Vector2()
```
```
The new object is
not
allocated on the heap, it is still allocated on the functions stack.
To quote
MSDN
:
When you create a struct object using
  the new operator, it gets created and
  the appropriate constructor is called.
  Unlike classes, structs can be
  instantiated without using the new
  operator.
If you do not use new,
the
  fields will remain unassigned and
the
object cannot be used
until all of the
  fields are initialized.