当前位置: 首页>>代码示例>>C#>>正文


C# Range.GetIntersection方法代码示例

本文整理汇总了C#中Range.GetIntersection方法的典型用法代码示例。如果您正苦于以下问题:C# Range.GetIntersection方法的具体用法?C# Range.GetIntersection怎么用?C# Range.GetIntersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Range的用法示例。


在下文中一共展示了Range.GetIntersection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetIntersectionShouldThrowExceptionIfItHasNoIntersection3

 public void GetIntersectionShouldThrowExceptionIfItHasNoIntersection3()
 {
     var a = new Range<int>(3);
     var b = new Range<int>(1, 2);
     Assert.Throws<InvalidOperationException>(() => a.GetIntersection(b));
 }
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:6,代码来源:RangeFixture.cs

示例2: GetIntersectionShouldThrowExceptionIfItHasNoIntersection8

 public void GetIntersectionShouldThrowExceptionIfItHasNoIntersection8()
 {
     var a = new Range<int>(4);
     var b = new Range<int>(null, 3);
     Assert.Throws<InvalidOperationException>(() => b.GetIntersection(a));
 }
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:6,代码来源:RangeFixture.cs

示例3: GetIntersectionShouldReturnValidRangeIfItHasIntersection

        public void GetIntersectionShouldReturnValidRangeIfItHasIntersection()
        {
            var a = new Range<int>(1, 3);
            var b = new Range<int>(2, 4);
            var c = a.GetIntersection(b);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(3, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(3, c.End);

            a = new Range<int>(2, 3);
            b = new Range<int>(1, 4);
            c = a.GetIntersection(b);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(3, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(3, c.End);

            a = new Range<int>(1, 3);
            b = new Range<int>(3, 4);
            c = a.GetIntersection(b);
            Assert.AreEqual(3, c.Start);
            Assert.AreEqual(3, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(3, c.Start);
            Assert.AreEqual(3, c.End);

            a = new Range<int>(2, 3);
            b = new Range<int>(1, 2);
            c = a.GetIntersection(b);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(2, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(2, c.End);

            a = new Range<int>(2, 3);
            b = new Range<int>(2, 3);
            c = a.GetIntersection(b);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(3, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(3, c.End);

            a = new Range<int>(2, 2);
            b = new Range<int>(2, 2);
            c = a.GetIntersection(b);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(2, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(2, c.End);

            a = new Range<int>(1);
            b = new Range<int>(2, 4);
            c = a.GetIntersection(b);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(4, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(4, c.End);

            a = new Range<int>(null, 3);
            b = new Range<int>(2, 4);
            c = a.GetIntersection(b);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(3, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(2, c.Start);
            Assert.AreEqual(3, c.End);

            a = new Range<int>(null, 3);
            b = new Range<int>(null, 4);
            c = a.GetIntersection(b);
            Assert.IsNull(c.Start);
            Assert.AreEqual(3, c.End);
            c = b.GetIntersection(a);
            Assert.IsNull(c.Start);
            Assert.AreEqual(3, c.End);

            a = new Range<int>(1);
            b = new Range<int>(2);
            c = a.GetIntersection(b);
            Assert.AreEqual(2, c.Start);
            Assert.IsNull(c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(2, c.Start);
            Assert.IsNull(c.End);

            a = new Range<int>(1);
            b = new Range<int>(null, 4);
            c = a.GetIntersection(b);
            Assert.AreEqual(1, c.Start);
            Assert.AreEqual(4, c.End);
            c = b.GetIntersection(a);
            Assert.AreEqual(1, c.Start);
            Assert.AreEqual(4, c.End);
//.........这里部分代码省略.........
开发者ID:jonathascosta,项目名称:SystemExtensions,代码行数:101,代码来源:RangeFixture.cs


注:本文中的Range.GetIntersection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。