本文整理汇总了C#中System.Web.UI.WebControls.ListItem.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# ListItem.GetHashCode方法的具体用法?C# ListItem.GetHashCode怎么用?C# ListItem.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.ListItem
的用法示例。
在下文中一共展示了ListItem.GetHashCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
HtmlForm frm = (HtmlForm)FindControl("Form1");
GHTTestBegin(frm);
// Call twice with the same instance should provide the same result.
this.GHTSubTestBegin("Two calls by the same object.");
try
{
bool flag1;
ListItem item1 = new ListItem("Text", "Value");
if (item1.GetHashCode() == item1.GetHashCode())
{
flag1 = true;
}
else
{
flag1 = false;
}
this.GHTSubTestAddResult(flag1.ToString());
}
catch (Exception exception5)
{
this.GHTSubTestUnexpectedExceptionCaught(exception5);
}
this.GHTSubTestEnd();
// Equal items (value equality, and not ref equality) should provide the same hashcode.
this.GHTSubTestBegin("Equal items ");
try
{
bool flag2;
ListItem item2 = new ListItem("Text", "Value");
ListItem item3 = new ListItem("Text", "Value");
if (item2.GetHashCode() == item3.GetHashCode())
{
flag2 = true;
}
else
{
flag2 = false;
}
this.GHTSubTestAddResult(flag2.ToString());
}
catch (Exception exception6)
{
this.GHTSubTestUnexpectedExceptionCaught(exception6);
}
this.GHTSubTestEnd();
// Not equal items (different text) should provide the diffrent hashcode.
this.GHTSubTestBegin("Not equal items ");
try
{
bool flag3;
ListItem item4 = new ListItem("Text1", "Value");
ListItem item5 = new ListItem("Text2", "Value");
if (item4.GetHashCode() == item5.GetHashCode())
{
flag3 = true;
}
else
{
flag3 = false;
}
this.GHTSubTestAddResult(flag3.ToString());
}
catch (Exception exception7)
{
// ProjectData.SetProjectError(exception7);
Exception exception3 = exception7;
this.GHTSubTestUnexpectedExceptionCaught(exception3);
// ProjectData.ClearProjectError();
}
this.GHTSubTestEnd();
// Not equal items (different value) should provide the diffrent hashcode.
this.GHTSubTestBegin("Not equal items ");
try
{
bool flag4;
ListItem item6 = new ListItem("Text", "Value1");
ListItem item7 = new ListItem("Text", "Value2");
if (item6.GetHashCode() == item7.GetHashCode())
{
flag4 = true;
}
else
{
flag4 = false;
}
this.GHTSubTestAddResult(flag4.ToString());
}
catch (Exception exception8)
{
// ProjectData.SetProjectError(exception8);
Exception exception4 = exception8;
this.GHTSubTestUnexpectedExceptionCaught(exception4);
// ProjectData.ClearProjectError();
}
//.........这里部分代码省略.........