C#自定义字段,数据类型

huangapple go评论82阅读模式
英文:

C# Custom field, data type

问题

我想在dot.net core中创建一个自定义字段,该字段将具有布尔值以及整数或字符串值,类似于以下内容:

public MyCustomField field;
field.BoolValue = true或false;
field.NumberValue = 101;

这是否可行?

英文:

I want to create a custom field in dot.net core which will have a bool as well as an integer or string value, something like the following:

Public MyCustomField field;
field.BoolValue = true or false;
field.NumberValue = 101;

Is this possible?

答案1

得分: 2

是的,它是。

void Main()
{
    field.BoolValue = true;
    field.NumberValue = 101;
}

public MyCustomField field;

public struct MyCustomField // or `class`
{
    public bool BoolValue;
    public int NumberValue;
}
英文:

Yes, it is.

void Main()
{
	field.BoolValue = true;
	field.NumberValue = 101;
}

public MyCustomField field;

public struct MyCustomField // or `class`
{
	public bool BoolValue;
	public int NumberValue;
}

huangapple
  • 本文由 发表于 2023年6月22日 08:46:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76527997.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定