-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] primitive struct as primitive #16095
Comments
Mildly related: #15079 |
Related to |
The enum part of this proposal sounds pretty similar to #6739. |
Have found idea #16193 I think my proposal could be extend a bit to cover this By count Like so it could be done as struct Thing
{
public Colors Color;
public Models Model;
}
enum Things : Thing
{
RedBox = new Thing(Models.Box,Colors.Red),
BlueBox = new Thing(Models.Box,Colors.Blue),
RedSphere = new Thing(Models.Sphere,Colors.Red),
BlueSphere = new Thing(Models.Sphere,Colors.Blue),
}
enum Colors : Color
{
Red: new Color(255,0,0),
Green: new Color(0,255,0),
Blue: new Color(0,0,255),
}
enum Models
{
Sphere:0,
Box:1,
}
////
var obj = Things.RedBox;
var objColor = Things.RedBox.Color; |
I don't remember why I close this issue, might be mistake. Is it possible to move this into https://github.com/dotnet/csharplang repo? |
Primitive type such as
string
andint
have a special ability. Such as make itconst
, 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 itThis should also cope with Tuple and other generic struct. If its generic contains only primitive it would became primitive
The text was updated successfully, but these errors were encountered: