I would like to use something similar as link! Part of the source code looks like that:
public struct Vector3
{
public static Vector3 zero { get; }
}
This function returns an already initialized Vector (which 0 on every axis). Is this possible, because it is a struct? That's what I have:
public class WorldBlock
{
public enum e_WorldBlockType
{
Undef,
Earth,
Stone,
Air // no block set
}
public static WorldBlock Empty { get; }
public e_WorldBlockType BlockType { get; set; }
public bool IsWalkable { get; set; }
public WorldBlock(e_WorldBlockType blockType = e_WorldBlockType.Undef, bool isWalkable = false)
{
this.BlockType = blockType;
this.IsWalkable = isWalkable;
}
}
But I get this: error CS0840: 'WorldBlock.Empty.get' must have a body because it is not marked abstract or extern. The property can be automatically implemented when you define both accessors
How should I write the body?
EDIT:
If I add for example a private set
, it compiles, but if I use it, I get a null pointer exception.