本文整理汇总了C#中System.Collections.ArrayList.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ArrayList.SetValue方法的具体用法?C# ArrayList.SetValue怎么用?C# ArrayList.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了ArrayList.SetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeValue
/// <devdoc>
/// Deserializes a single value from the underlying stream.
/// Essentially a token is read, followed by as much data needed to recreate
/// the single value.
/// </devdoc>
private object DeserializeValue(SerializerBinaryReader reader) {
byte token = reader.ReadByte();
// NOTE: Preserve the order here with the order of the logic in
// the SerializeValue method.
switch (token) {
case Token_Null:
return null;
case Token_EmptyString:
return String.Empty;
case Token_String:
return reader.ReadString();
case Token_ZeroInt32:
return 0;
case Token_Int32:
return reader.ReadEncodedInt32();
case Token_Pair:
return new Pair(DeserializeValue(reader),
DeserializeValue(reader));
case Token_Triplet:
return new Triplet(DeserializeValue(reader),
DeserializeValue(reader),
DeserializeValue(reader));
case Token_IndexedString:
case Token_IndexedStringAdd:
return DeserializeIndexedString(reader, token);
case Token_ArrayList:
{
int count = reader.ReadEncodedInt32();
ArrayList list = new ArrayList(count);
for (int i = 0; i < count; i++) {
list.Add(DeserializeValue(reader));
}
return list;
}
case Token_True:
return true;
case Token_False:
return false;
case Token_Byte:
return reader.ReadByte();
case Token_Char:
return reader.ReadChar();
case Token_DateTime:
return DateTime.FromBinary(reader.ReadInt64());
case Token_Double:
return reader.ReadDouble();
case Token_Int16:
return reader.ReadInt16();
case Token_Single:
return reader.ReadSingle();
case Token_Hashtable:
case Token_HybridDictionary:
{
int count = reader.ReadEncodedInt32();
IDictionary table;
if (token == Token_Hashtable) {
table = new Hashtable(count);
}
else {
table = new HybridDictionary(count);
}
for (int i = 0; i < count; i++) {
table.Add(DeserializeValue(reader),
DeserializeValue(reader));
}
return table;
}
case Token_Type:
return DeserializeType(reader);
case Token_StringArray:
{
int count = reader.ReadEncodedInt32();
string[] array = new string[count];
for (int i = 0; i < count; i++) {
array[i] = reader.ReadString();
}
return array;
}
case Token_Array:
{
Type elementType = DeserializeType(reader);
int count = reader.ReadEncodedInt32();
Array list = Array.CreateInstance(elementType, count);
for (int i = 0; i < count; i++) {
list.SetValue(DeserializeValue(reader), i);
}
//.........这里部分代码省略.........