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


C# NameValueCollection.CopyTo方法代码示例

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


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

示例1: ResourceId

        public ResourceId(NameValueCollection parameters)
        {
            this.parameters = parameters;

            string[] values = new string[parameters.Keys.Count];
            parameters.CopyTo(values, 0);
            internalValue = string.Join(Environment.NewLine, values);
        }
开发者ID:JunctionBoxca,项目名称:Rest-In-Practise-Product-Catalog-Service,代码行数:8,代码来源:ResourceId.cs

示例2: CopyTo_WrongTypeArray

		public void CopyTo_WrongTypeArray ()
		{
			Array a = Array.CreateInstance (typeof (DateTime), 3);
			NameValueCollection c = new NameValueCollection ();
			for (int i = 0; i < 3; i++)
				c.Add(i.ToString(), i.ToString());
			c.CopyTo(a, 0);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:NameValueCollectionTest.cs

示例3: CopyTo_MultipleDimensionArray

		public void CopyTo_MultipleDimensionArray () 
		{
			Array a = Array.CreateInstance (typeof (string), 1, 2, 3);
			NameValueCollection c = new NameValueCollection ();
			c.CopyTo (a, 0);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:6,代码来源:NameValueCollectionTest.cs

示例4: CopyTo_MultipleDimensionStringArray

		public void CopyTo_MultipleDimensionStringArray () 
		{
			string [,,] matrix = new string [2,3,4];
			NameValueCollection c = new NameValueCollection ();
			c.Add ("1", "mono");
			c.Add ("2", "MoNo");
			c.Add ("3", "mOnO");
			c.Add ("4", "MONO");
			c.CopyTo (matrix, 0);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:NameValueCollectionTest.cs

示例5: CopyTo_NotEnoughSpace

		public void CopyTo_NotEnoughSpace () 
		{
			string [] array = new string [4];
			NameValueCollection c = new NameValueCollection ();
			c.Add ("1", "mono");
			c.Add ("2", "MoNo");
			c.Add ("3", "mOnO");
			c.Add ("4", "MONO");
			c.CopyTo (array, 2);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:NameValueCollectionTest.cs

示例6: CopyTo_NegativeIndex

		public void CopyTo_NegativeIndex () 
		{
			string [] array = new string [4];
			NameValueCollection c = new NameValueCollection ();
			c.Add ("1", "mono");
			c.Add ("2", "MoNo");
			c.Add ("3", "mOnO");
			c.Add ("4", "MONO");
			c.CopyTo (array, -1);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:NameValueCollectionTest.cs

示例7: CopyTo_Null

		public void CopyTo_Null () 
		{
			NameValueCollection c = new NameValueCollection ();
			c.CopyTo (null, 0);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:NameValueCollectionTest.cs

示例8: Test01

        public void Test01()
        {
            IntlStrings intl;
            NameValueCollection nvc;

            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aA",
                "text",
                "     SPaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            // keys for simple string values
            string[] keys =
            {
                "zero",
                "oNe",
                " ",
                "",
                "aa",
                "1",
                System.DateTime.Today.ToString(),
                "$%^#",
                Int32.MaxValue.ToString(),
                "     spaces",
                "2222222222222222222222222"
            };

            string[] destination;
            int cnt = 0;            // Count

            // initialize IntStrings
            intl = new IntlStrings();


            // [] NameValueCollection is constructed as expected
            //-----------------------------------------------------------------

            nvc = new NameValueCollection();

            // [] CopyTo() empty collection into empty array
            //
            destination = new string[] { };
            try
            {
                nvc.CopyTo(destination, -1);
                Assert.False(true, "Error, no exception");
            }
            catch (ArgumentOutOfRangeException)
            {
            }
            catch (Exception e)
            {
                Assert.False(true, string.Format("Error, unexpected exception: {0}", e.ToString()));
            }

            try
            {
                nvc.CopyTo(destination, 0);
            }
            catch (Exception e)
            {
                Assert.False(true, string.Format("Error, unexpected exception: {0}", e.ToString()));
            }

            try
            {
                nvc.CopyTo(destination, 1);
                Assert.False(true, "Error, no exception");
            }
            catch (ArgumentException)
            {
            }
            catch (Exception e)
            {
                Assert.False(true, string.Format("Error, unexpected exception: {0}", e.ToString()));
            }

            // [] CopyTo() empty collection into filled array
            //
            destination = new string[values.Length];
            for (int i = 0; i < values.Length; i++)
            {
                destination[i] = values[i];
            }
            nvc.CopyTo(destination, 0);
            if (destination.Length != values.Length)
            {
                Assert.False(true, "Error, altered array after copying empty collection");
            }
            if (destination.Length == values.Length)
//.........这里部分代码省略.........
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:CopyToArrayIntTests.cs

示例9: NameValueCollectionSource

        public void NameValueCollectionSource()
        {
            var source = new NameValueCollection();

            // guid
            var guidValue = new Guid("21EC2020-3AEA-1069-A2DD-08002B30309D");

            source["GuidPty"] = guidValue.ToString();
            Assert.AreEqual(guidValue, source.CopyTo<TargetType>().GuidPty);

            // int
            source["IntPty"] = 345.ToString(CultureInfo.InvariantCulture);
            Assert.AreEqual(345, source.CopyTo<TargetType>().IntPty);

            // enum pty
            source["EnumPty"] = TargetType.TestEnum.Three.ToString();
            Assert.AreEqual(TargetType.TestEnum.Three, source.CopyTo<TargetType>().EnumPty);
        }
开发者ID:Sinbadsoft,项目名称:Sinbadsoft.Lib.Model,代码行数:18,代码来源:DictionarySourceTest.cs

示例10: GetRouteData

        private RouteData GetRouteData(ContentTreeNode treeNode, HttpContextBase httpContext)
        {
            var routeData = GetRouteData(treeNode);
            var queryString = HttpUtility.ParseQueryString(httpContext.Request.Url.Query);
            var queryStringCollectionToCopy = new NameValueCollection();
            foreach (var item in queryString.Keys)
            {
                if (item != null)
                {
                    queryStringCollectionToCopy.Add(item.ToString(), queryString[item.ToString()]);
                }
            }
            queryStringCollectionToCopy.CopyTo(routeData.Values);

            return routeData;
        }
开发者ID:burkhartt,项目名称:Bennington,代码行数:16,代码来源:ContentRoute.cs


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