本文整理汇总了C#中ICollection.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.ToString方法的具体用法?C# ICollection.ToString怎么用?C# ICollection.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createOutPutFiles
private void createOutPutFiles(ICollection<string> fileToWrite, string fileName)
{
StreamWriter fs = new System.IO.StreamWriter(Path.GetFullPath(Server.MapPath(System.DateTime.Now.ToString(DateFormat) + fileName)), true);
fs.Write(fileToWrite.ToString());
fs.Close();
}
示例2: SetCollectionItems
//.........这里部分代码省略.........
{
// IDictionary
IDictionary dict = (IDictionary)coll;
IDictionaryEnumerator de = dict.GetEnumerator();
while (de.MoveNext())
{
object key = de.Key;
//object val = de.Value;
XmlElement itemnode = parent.OwnerDocument.CreateElement(XmlSerializationTag.ITEM);
collnode.AppendChild(itemnode);
object curr = de.Current;
XmlElement propsnode = parent.OwnerDocument.CreateElement(XmlSerializationTag.PROPERTIES);
itemnode.AppendChild(propsnode);
PropertyInfo[] piarr = curr.GetType().GetProperties();
for (int i = 0; i < piarr.Length; i++)
{
PropertyInfo pik = piarr[i];
SetProperty(curr, pik, propsnode);
}
}
}
else
{
// Everything else
IEnumerator ie = coll.GetEnumerator();
while (ie.MoveNext())
{
object obj2 = ie.Current;
XmlElement itemnode = parent.OwnerDocument.CreateElement(XmlSerializationTag.ITEM);
if (obj2 != null)
{
SetObjectInfoAttributes(null, obj2.GetType(), itemnode);
}
else
{
SetObjectInfoAttributes(null, null, itemnode);
}
itemnode.Attributes[XmlSerializationTag.NAME].Value = "" + cnt;
cnt++;
collnode.AppendChild(itemnode);
if (obj2 == null)
{ continue; }
Type pt = obj2.GetType();
if (TypeInfo.IsCollection(pt))
{
SetCollectionItems(obj, (ICollection)obj2, itemnode);
}
else
{
bool complexclass = false;
XmlElement propsnode = null;
PropertyInfo[] piarr2 = pt.GetProperties();
for (int j = 0; j < piarr2.Length; j++)
{
PropertyInfo pi2 = piarr2[j];
if ((pi2.PropertyType.IsSerializable || IgnoreSerializableAttribute) && (pi2.CanWrite) && ((pi2.PropertyType.IsPublic) || (pi2.PropertyType.IsEnum)))
{
if (propsnode == null)
{
propsnode = parent.OwnerDocument.CreateElement(XmlSerializationTag.PROPERTIES);
itemnode.AppendChild(propsnode);
}
complexclass = true;
SetProperty(obj2, pi2, propsnode);
}
}
if (!complexclass)
{
TypeConverter tc = TypeDescriptor.GetConverter(pt);
if (tc.CanConvertTo(typeof(string)))
{
object val = (string)tc.ConvertTo(obj2, typeof(string));
itemnode.InnerText = val.ToString();
}
else
{
itemnode.InnerText = value.ToString();
}
} // complexclass?
} // IsCollection?
} // Loop collection
} // IsDictionary?
}
示例3: ToString_String_Collection_Returns_Valid_Result
public void ToString_String_Collection_Returns_Valid_Result(ICollection<string> col, string separator, string expectedResult)
{
Assert.That(() => col.ToString(separator), Is.EqualTo(expectedResult));
}