[英]Maximum/Minimum Object
In C#, is there a build-in-class that is intended for storing minimum and maximum values as doubles? 在C#中,是否有用于将最小值和最大值存储为double的内置类?
The Point listed here http://msdn.microsoft.com/en-us/library/system.windows.point.point(v=vs.110).aspx would word perfectly, except I cannot create this Point. http://msdn.microsoft.com/zh-cn/library/system.windows.point.point(v=vs.110).aspx上列出的Point可以完美地表达,除非我无法创建此Point。 I don't think it is supported with what I am doing.
我认为我所做的事情不支持它。 I just get the Point(int, int), the
System.Drawing
one. 我只是得到Point(int,int),
System.Drawing
一个。 It is not letting add using System.Window
. 不允许使用
System.Window
添加。
So for storing 2 doubles, what do you recommend? 那么要存储2个双打,您有什么建议? Create my own class, actually use 2 doubles (ugh), or is there some other Object I can use?
创建我自己的类,实际使用2个double(ugh),还是我可以使用其他一些对象?
The Point
class is actually System.Windows.Point
not System.Window.Point
. Point
类实际上是System.Windows.Point
而不是System.Window.Point
。 Is that your problem? 那是你的问题吗?
Failing that, you could use a Tuple
- this generic class holds two values of any type. 否则,您可以使用
Tuple
-该泛型类包含两个任何类型的值。 So Tuple<double, double>
would give you two doubles, accessed as thing.Item1
and thing.Item2
因此,
Tuple<double, double>
将为您提供两个double,分别作为thing.Item1
和thing.Item2
访问
But seriously, if you want to store a minimum and maximum, you should really create a class with two double values named Minimum
and Maximum
. 但是,认真的说,如果要存储最小值和最大值,则应该真正创建一个包含两个双精度值的类,分别名为
Minimum
和Maximum
。 Don't go using some unrelated type like Point
just to save a couple of lines of typing. 不要只使用
Point
等无关的类型来节省几行输入。
我将创建一个自定义类,并将其命名为与两个双打的含义相关的名称
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.