本文整理汇总了C#中Range.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Distance方法的具体用法?C# Range.Distance怎么用?C# Range.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.Distance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: distance_value
public void distance_value() {
var a = new Range(0, 0);
var b = new Range(-1, 1);
var c = new Range(5, -10);
Assert.Equal(0, a.Distance(0));
Assert.Equal(2, a.Distance(2));
Assert.Equal(0, b.Distance(1));
Assert.Equal(3, b.Distance(-4));
Assert.Equal(1, b.Distance(-2));
Assert.Equal(1, b.Distance(2));
Assert.Equal(0, c.Distance(1));
Assert.Equal(0, c.Distance(3));
Assert.Equal(3, c.Distance(8));
Assert.Equal(10, c.Distance(-20));
}
示例2: distance_range
public void distance_range() {
var a = new Range(0, 0);
var b = new Range(1, 1);
var c = new Range(1, 2);
var d = new Range(3, 2);
var e = new Range(-2, -1);
Assert.Equal(0, a.Distance(a));
Assert.Equal(0, b.Distance(b));
Assert.Equal(1, a.Distance(b));
Assert.Equal(1, b.Distance(a));
Assert.Equal(0, c.Distance(d));
Assert.Equal(0, d.Distance(c));
Assert.Equal(2, c.Distance(e));
Assert.Equal(2, e.Distance(c));
}