猿问

c#定义结构体不能用?

class xx{
public static struct date
{
string mname;
string mpass;
}
class memory
{

public static date[] creatmemory()
{
date[] mymemory =new date[10];
return mymemory;
}
public static void writememory(date[] m,string na,string pa)

m.mname = na;
m.mpass = pa;
}
}
提示不包含定义,或using引用

慕勒3428872
浏览 1021回答 2
2回答

jeck猫

m 是date[] 下面这么调用出问题了m.mname = na;m.mpass =&nbsp;pa;修改成下面的class xx{public struct date{public string mname;public string mpass;}class memory{public static date[] creatmemory(){date[] mymemory = new date[10];return mymemory;}public static void writememory(date[] m, string na, string pa){for (var i = 0; i < m.Length; i++){m[i].mname = na;m[i].mpass = pa;}}}}&nbsp;
随时随地看视频慕课网APP
我要回答