using System;namespace Award
{
/// <summary>
/// AllUser 的摘要说明。
/// </summary>
public class AllUser
{
private string  KjName;
private string Kjval; public AllUser(string _name,string _val)
{
KjName=_name.ToString();
Kjval=_val.ToString();
}
public string kjName
{
get
{
return KjName;
}
set
{
KjName=value;
}
} public string kjval
{
get
{
return Kjval;
}
set
{
Kjval=value;
}
}
}
}这个类我平时使用时候 我定义如下
AllUser ss =new AllUser("asd","fff");
我如果我想创建数组怎么写这个代码???
向高手请教

解决方案 »

  1.   

    using System;
    class Method
    {
    public static float VarLenParam(params long[]v)
    {
    long total,i;
    for(i=0,total=0;i<v.Length;++i)
    total+=v[i];
    return(float)total/v.Length;
    }
    static void Main()
    {
    float x = VarLenParam(1,2,3,4);
    Console.WriteLine("1+2+3+4 的平均值为{0}",x);
    x=VarLenParam(1,2,3,4,5);
    Console.WriteLine("1+2+3+4+5 的平均值为{0}",x);
    }
    }
    ============================
    差不多就是这个意思了
      

  2.   

    AllUser[] s =new AllUser[] ???
    我添加数据怎么弄?
      

  3.   

    数组的长度不知道就用ArrayList
      

  4.   

    ArrayList temp = new ArrayList();
    temp.add(new AllUser("asd","fff"));
    temp.add(new AllUser("as12","fff"));
    temp.add(new AllUser("as12","fff"));
    temp.add(new AllUser("as342","fff"));
    AllUser[] a = (AllUser[]) temp.ToArray(typeof(AllUser));大概是这样吧,我没编译.
      

  5.   

    恩 whyxx(java?.net?我们要学会用两条腿走路) 谢谢啦
      

  6.   

    数组的长度未定就用ArrayList,ArrayList是动态的数组,你只要把AllUser换成ArrayList就行了