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


C# DynamicArray.AddRange方法代码示例

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


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

示例1: TestMethod1

        public void TestMethod1()
        {
            try
            {
                DynamicArray<int> m1 = new DynamicArray<int>();
                DynamicArray<int> m2 = new DynamicArray<int>(9);

                int[] arr = new[] { 1, 2, 3, 4, 5 };
                DynamicArray<int> m3 = new DynamicArray<int>(arr);

                var a = m3.Length;
                Assert.AreEqual(a, 5);
                var b = m3.Capacity;
                Assert.AreEqual(b, 5);

                m3.Add(6);
                var a1 = m3.Length;
                Assert.AreEqual(a1, 6);
                var b1 = m3.Capacity;
                Assert.AreEqual(b1, 10);

                int[] arr1 = new[] { 7, 8, 9, 10, 11, 12 };
                m3.AddRange(arr1);
                var a3 = m3.Length;
                Assert.AreEqual(a3, 12);
                var b3 = m3.Capacity;
                Assert.AreEqual(b3, 20);

                var flag1 = m3.Remove(7);
                var a4 = m3.Length;
                Assert.AreEqual(a4, 11);
                Assert.AreEqual(flag1, true);

                //m3.Insert(26,14); //Попытка вставить вне границ массива
                m3.Insert(6, 7);
                var b4 = m3[6];
                Assert.AreEqual(b4, 7);

                int k = 1;
                foreach (var elem in m3)
                {
                    var a5 = elem;
                    Assert.AreEqual(a5, k);
                    k++;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Assert.AreEqual(0, 1);

            }
        }
开发者ID:Bulat15,项目名称:repository2,代码行数:53,代码来源:UnitTest1.cs

示例2: AddRangeMoreThanCapacity

 public void AddRangeMoreThanCapacity()
 {
     int[] a = { 28, 98, 89, 25, 43 };
     DynamicArray<int> Arr = new DynamicArray<int>(2);
     Arr.Add(68);
     Arr.Add(73);
     Arr.AddRange(a);
     Assert.AreEqual(Arr.Length, 7);
     Assert.AreEqual(Arr.Capacity, 8);
     Assert.AreEqual(Arr[2], 28);
     Assert.AreEqual(Arr[6], 43);
 }
开发者ID:PozdeyevArtyom,项目名称:megarepository,代码行数:12,代码来源:Task03Tests.cs

示例3: AddRangeTest

 public void AddRangeTest()
 {
     int i;
     DynamicArray<int> testArr = new DynamicArray<int>(4);
     int[] A = new int[] { 1, 2, 3, 4, 5 };
     testArr.AddRange(A);
     for (i = 0; i < 5; i++)
     {
         Assert.AreEqual(testArr[i], i + 1);
     }
     Assert.AreEqual(testArr.Length, 5);
 }
开发者ID:Laetar,项目名称:Epam,代码行数:12,代码来源:CriticalMetodTest.cs

示例4: TestAddRangeMethodWithIncCapacity

        public void TestAddRangeMethodWithIncCapacity()
        {
            DynamicArray<int> m2 = new DynamicArray<int>(2);
            int[] arr1 = new[] { 7, 8, 9, 10, 11, 12 };
            m2.AddRange(arr1);
            var a1 = m2.Length;
            Assert.AreEqual(a1, 6);
            var b1 = m2.Capacity;
            Assert.AreEqual(b1, 8);

            var a3 = m2[5];
            Assert.AreEqual(a3, 12);
        }
开发者ID:egorbulychev127,项目名称:Repository1,代码行数:13,代码来源:TestAddRangeWithIncreaseCapacity.cs

示例5: AddRangeTest

 public void AddRangeTest()
 {
     int i;
     int[] A = new int[] { 1, 2, 3, 4 };
     int[] B = new int[] { 5, 6, 7, 8 , 9};
     DynamicArray<int> testArr = new DynamicArray<int>(A);
     testArr.AddRange(B);
     for (i = 0; i < 9; i++)
     {
         Assert.AreEqual(testArr[i], i+1);
     }
     Assert.AreEqual(testArr.Length, 9);
 }
开发者ID:Laetar,项目名称:Epam,代码行数:13,代码来源:MetodTest.cs

示例6: TestMethod1

        public void TestMethod1()
        {
            try
            {
                DynamicArray<int> arr1 = new DynamicArray<int>();
                DynamicArray<int> arr2 = new DynamicArray<int>(20);

                int[] arr3 = new[] { 1, 2, 3, 4, 5 };
                DynamicArray<int> arr4 = new DynamicArray<int>(arr3);

                var a = arr4.Length;
                Assert.AreEqual(a, 5);
                var b = arr4.Capacity;
                Assert.AreEqual(b, 5);

                arr4.Add(6);
                var a1 = arr4.Length;
                Assert.AreEqual(a1, 6);
                var b1 = arr4.Capacity;
                Assert.AreEqual(b1, 10);

                int[] arr31 = new[] { 7, 8, 9, 10, 11, 12 };
                arr4.AddRange(arr31);
                var a3 = arr4.Length;
                Assert.AreEqual(a3, 12);
                var b3 = arr4.Capacity;
                Assert.AreEqual(b3, 20);

                var flag1 = arr4.Remove(7);
                var a4 = arr4.Length;
                Assert.AreEqual(a4, 11);
                Assert.AreEqual(flag1, true);

                arr4.Insert(6, 7);
                var b4 = arr4[6];
                Assert.AreEqual(b4, 7);

                int k = 1;
                foreach (var elem in arr4)
                {
                    var a5 = elem;
                    Assert.AreEqual(a5, k);
                    k++;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Assert.AreEqual(0, 1);
            }
        }
开发者ID:AlbinaKuptsova,项目名称:Kuptsova_Albina,代码行数:51,代码来源:UnitTest1.cs


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