本文整理汇总了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);
}
示例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);
}
示例3: CopyTo_MultipleDimensionArray
public void CopyTo_MultipleDimensionArray ()
{
Array a = Array.CreateInstance (typeof (string), 1, 2, 3);
NameValueCollection c = new NameValueCollection ();
c.CopyTo (a, 0);
}
示例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);
}
示例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);
}
示例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);
}
示例7: CopyTo_Null
public void CopyTo_Null ()
{
NameValueCollection c = new NameValueCollection ();
c.CopyTo (null, 0);
}
示例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)
//.........这里部分代码省略.........
示例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);
}
示例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;
}