本文整理汇总了C#中System.Web.UI.WebControls.ListItem.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# ListItem.Equals方法的具体用法?C# ListItem.Equals怎么用?C# ListItem.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.ListItem
的用法示例。
在下文中一共展示了ListItem.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
HtmlForm frm = (HtmlForm) (HtmlForm)this.FindControl("Form1");
this.GHTTestBegin(frm);
// SubTest Reference equality
this.GHTSubTestBegin("Reference equality");
try
{
System.Web.UI.WebControls.ListItem item1 = new System.Web.UI.WebControls.ListItem("Text", "Value");
System.Web.UI.WebControls.ListItem item2 = item1;
Compare(item1.Equals(item2), true);
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTSubTestEnd();
GHTTestBegin(frm);
// SubTest Text & Value equal, but selected is not equal
GHTSubTestBegin("Text & Value equal, but selected is not equal");
try
{
System.Web.UI.WebControls.ListItem item3 = new System.Web.UI.WebControls.ListItem("Text", "Value");
item3.Selected = true;
System.Web.UI.WebControls.ListItem item4 = new System.Web.UI.WebControls.ListItem("Text", "Value");
item4.Selected = false;
Compare(item3.Equals(item4), true);
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTSubTestEnd();
// SubTest Values are not equal
GHTSubTestBegin("Values are not equal");
try
{
System.Web.UI.WebControls.ListItem item5 = new System.Web.UI.WebControls.ListItem("Text", "Value1");
System.Web.UI.WebControls.ListItem item6 = new System.Web.UI.WebControls.ListItem("Text", "Value2");
Compare(item5.Equals(item6), false);
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTSubTestEnd();
// SubTest Texts are not equal
GHTSubTestBegin("Texts are not equal");
try
{
System.Web.UI.WebControls.ListItem item7 = new System.Web.UI.WebControls.ListItem("Text1", "Value");
System.Web.UI.WebControls.ListItem item8 = new System.Web.UI.WebControls.ListItem("Text2", "Value");
Compare(item7.Equals(item8), false);
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTSubTestEnd();
// SubTest FakeListItem
GHTSubTestBegin("FakeListItem");
try
{
System.Web.UI.WebControls.ListItem item9 = new System.Web.UI.WebControls.ListItem("Text", "Value");
FakeListItem item10 = new FakeListItem("Text", "Value");
Compare(item9.Equals(item10), false);
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTSubTestEnd();
GHTTestEnd();
}