救助!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
webclass.cs
using System;
using System.Data;
using System.Configuration;
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;
/// <summary>
/// webclass 的摘要说明
/// </summary>
///
namespace myweb
{
public class webclass
{
//生成随机数
private string RndNum(int Va)
{
string RndChar = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,5,6,7,8,9 ";
string[] NumArray = RndChar.Split(new char[] { ', ' });
string Num = " ";
int i;
Random Rnd = new Random();
for (i = 0; i < Va; i++)
{
int N = Rnd.Next(35);
Num += NumArray[N];
}
return Num;
}
}
}
default.cs
using System;
using System.Data;
using System.Configuration;
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;
using myweb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
webclass a = new webclass();
Response.Write(a.RndNum(4));//这里会出错
}
}
------解决方案--------------------你怎么敢让它访问私有方法???
------解决方案--------------------int N = Rn