本文整理汇总了C#中StringDictionary.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# StringDictionary.GetType方法的具体用法?C# StringDictionary.GetType怎么用?C# StringDictionary.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringDictionary
的用法示例。
在下文中一共展示了StringDictionary.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";
StringDictionary sd;
try
{
Console.WriteLine("--- default ctor ---");
strLoc = "Loc_001oo";
iCountTestcases++;
sd = new StringDictionary();
Console.WriteLine("1. compare to null");
iCountTestcases++;
if (sd == null)
{
iCountErrors++;
Console.WriteLine("Err_0001, collection is null after default ctor");
}
Console.WriteLine("2. check Count");
iCountTestcases++;
if (sd.Count != 0)
{
iCountErrors++;
Console.WriteLine("Err_0002, Count = {0} after default ctor", sd.Count);
}
Console.WriteLine("3. check ContainsValue()");
iCountTestcases++;
if (sd.ContainsValue("string"))
{
iCountErrors++;
Console.WriteLine("Err_0003, ContainsValue() returned true after default ctor");
}
Console.WriteLine("4. check ContainsKey()");
iCountTestcases++;
if (sd.ContainsKey("string"))
{
iCountErrors++;
Console.WriteLine("Err_0004, ContainsKey() returned true after default ctor");
}
Console.WriteLine("5. check ToString()");
iCountTestcases++;
string temp = sd.ToString();
Console.WriteLine(" ToString(): " + temp);
if (temp.IndexOf("StringDictionary") == -1)
{
iCountErrors++;
Console.WriteLine("Err_0005, ToString() doesn't contain \"StringDictionary\"");
}
Console.WriteLine("6. check returned Type");
iCountTestcases++;
temp = sd.GetType().ToString().Trim();
Console.WriteLine(" GetType(): " + temp);
if (temp.IndexOf("StringDictionary") == -1)
{
iCountErrors++;
Console.WriteLine("Err_0006: returned type doesn't contain \"StringDictionary\"");
}
Console.WriteLine("7. compare returned Type of two Dictionaries");
iCountTestcases++;
string temp1 = (new StringDictionary()).GetType().ToString().Trim();
if (String.Compare(temp, temp1) != 0)
{
iCountErrors++;
Console.WriteLine("Err_0007: returned types of two collections differ");
}
Console.WriteLine("8. check IsSynchronized");
iCountTestcases++;
Console.WriteLine(" IsSynchronized: " + sd.IsSynchronized);
if (sd.IsSynchronized)
{
iCountErrors++;
Console.WriteLine("Err_0008: IsSynchronized returned {0}", sd.IsSynchronized);
}
Console.WriteLine("9. add item and verify");
iCountTestcases++;
sd.Add("key", "value");
iCountTestcases++;
if (sd.Count != 1)
{
iCountErrors++;
Console.WriteLine("Err_0009a: Count returned {0}", sd.Count);
}
iCountTestcases++;
if ( !sd.ContainsKey("key") )
{
iCountErrors++;
Console.WriteLine("Err_0009b: ContainsKey() returned false");
}
iCountTestcases++;
if ( !sd.ContainsValue("value") )
{
iCountErrors++;
Console.WriteLine("Err_0009c: ContainsValue() returned false");
}
}
catch (Exception exc_general )
{
++iCountErrors;
//.........这里部分代码省略.........