Open
Description
openedon Dec 24, 2016
Primitive type such as string
and int
have a special ability. Such as make it const
, use it on default parameter (because it is const), or make it a base class of enum (actually it only for integer but that also included in this proposal)
I think it useful if we could have struct that contain only primitive things also being primitive. And if it contains only integer it should also be integer. So struct that which is primitive can be const
field. Can be set default parameter. And if it is integer struct it would be able to make enum from it
public struct Color
{
public byte R,G,B,A;
}
public enum Colors : Color // all field is byte so it is also integer
{
Red = new Color(255,0,0,255),
Green = new Color(0,255,0,255),
Blue = new Color(0,0,255,255),
}
public struct Vector3
{
public float X,Y,Z;
public const Zero = new Vector3(0,0,0);
}
public struct Config
{
public Vector3 Up;
public string Name;
public static void SetConfigToEnv(Config con = new Config("test",new Vector3(0,1,0)))
{
}
}
This should also cope with Tuple and other generic struct. If its generic contains only primitive it would became primitive
Activity