本文整理汇总了C#中ListDictionary.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ListDictionary.GetType方法的具体用法?C# ListDictionary.GetType怎么用?C# ListDictionary.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListDictionary
的用法示例。
在下文中一共展示了ListDictionary.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runTest
public virtual bool runTest()
{
Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
ListDictionary ld;
try
{
Console.WriteLine("--- default ctor ---");
strLoc = "Loc_001oo";
iCountTestcases++;
ld = new ListDictionary();
Console.WriteLine("1. compare to null");
iCountTestcases++;
if (ld == null)
{
iCountErrors++;
Console.WriteLine("Err_0001, dictionary is null after default ctor");
}
Console.WriteLine("2. check Count");
iCountTestcases++;
if (ld.Count != 0)
{
iCountErrors++;
Console.WriteLine("Err_0002, Count = {0} after default ctor", ld.Count);
}
Console.WriteLine("3. check Item(some_key)");
iCountTestcases++;
if (ld["key"] != null)
{
iCountErrors++;
Console.WriteLine("Err_0003, Item(some_key) returned non-null after default ctor");
}
Console.WriteLine("4. check ToString()");
iCountTestcases++;
string temp = ld.ToString();
Console.WriteLine(" ToString(): " + temp);
if (temp.IndexOf("ListDictionary") == -1)
{
iCountErrors++;
Console.WriteLine("Err_0004, ToString() doesn't contain \"ListDictionary\"");
}
Console.WriteLine("5. check returned Type");
iCountTestcases++;
temp = ld.GetType().ToString().Trim();
Console.WriteLine(" GetType(): " + temp);
if (temp.IndexOf("ListDictionary") == -1)
{
iCountErrors++;
Console.WriteLine("Err_0005: returned type doesn't contain \"ListDictionary\"");
}
Console.WriteLine("6. compare returned Type of two dictionary");
iCountTestcases++;
string temp1 = (new ListDictionary()).GetType().ToString().Trim();
if (String.Compare(temp, temp1) != 0)
{
iCountErrors++;
Console.WriteLine("Err_0006: returned types of two collections differ");
}
Console.WriteLine("7. check Keys collection");
iCountTestcases++;
System.Collections.ICollection keys = ld.Keys;
if ( keys.Count != 0)
{
iCountErrors++;
Console.WriteLine("Err_0007: Keys contains {0} keys after default ctor", keys.Count);
}
Console.WriteLine("8. check Values collection");
iCountTestcases++;
System.Collections.ICollection values = ld.Values;
if ( values.Count != 0)
{
iCountErrors++;
Console.WriteLine("Err_0008: Values contains {0} items after default ctor", values.Count);
}
Console.WriteLine("9. Add(name, value)");
iCountTestcases++;
ld.Add("Name", "Value");
if (ld.Count != 1)
{
iCountErrors++;
Console.WriteLine("Err_0009a: Count returned {0} instead of 1", ld.Count);
}
if (String.Compare(ld["Name"].ToString(), "Value", false) != 0)
{
iCountErrors++;
Console.WriteLine("Err_0009b: Item() returned unexpected value");
}
Console.WriteLine("10. Clear()");
iCountTestcases++;
ld.Clear();
if (ld.Count != 0)
{
iCountErrors++;
Console.WriteLine("Err_00010a: Count returned {0} instead of 0 after Clear()", ld.Count);
}
if (ld["Name"] != null)
{
iCountErrors++;
//.........这里部分代码省略.........