当前位置: 首页>>代码示例>>C#>>正文


C# ListItem.GetHashCode方法代码示例

本文整理汇总了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();
			}
//.........这里部分代码省略.........
开发者ID:nobled,项目名称:mono,代码行数:101,代码来源:ListItem_GetHashCode_.aspx.cs


注:本文中的System.Web.UI.WebControls.ListItem.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。