62,046
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string x = "sss";
Byte[] y = System.Text.Encoding.Default.GetBytes(x);
string i = "sss";
Byte[] j = System.Text.Encoding.Default.GetBytes(i);
if (y.Length == j.Length) //首先判断长度是否相等
{
int len = y.Length; //数组长度
int mark = 0; //相等的标记,1表示相等
for (int flag = 0; flag < len; flag++)
{
if (y.GetValue(flag).ToString().Trim() == j.GetValue(flag).ToString().Trim())
{
mark = 1;
}
else
{
break;
}
}
if (mark == 1)
{
Response.Write("数组相等!");
Response.End();
}
else
{
Response.Write("数组不相等!");
Response.End();
}
}
else
{
Response.Write("数组不相等!");
Response.End();
}
}
}
if (第一个数组.Equals(第二个数组))
{
}
else
{
}
public static bool ByteEquals(byte[] x, byte[] y)
{
if (x.Length == y.Length)
{
for (int i = 0; i < x.Length; i++)
{
if (x.GetValue(i).ToString().Trim() != y.GetValue(i).ToString().Trim())
{
return false;
}
}
return true;
}
return false;
}