enter link description here我试图让(private int vr;)在循环中工作,所以我可以轻松地改变它,但是我不知道如何为此做一个get / set,或者如果我有完全使用get set。 我希望这是足够的信息,如果需要进一步的信息,请发表评论说。
struct mp3players
{
private int ID;
private string Make;
private string Model;
private int MBSize;
private double Price;
private int vr;
public int id
{
get { return this.ID; }
set { this.ID = value; }
}
public string make
{
get { return this.Make; }
set { this.Make = value; }
}
public string model
{
get { return this.Model; }
set { this.Model = value; }
}
public int mbsize
{
get { return this.MBSize; }
set { this.MBSize = value; }
}
public double price
{
get { return this.Price; }
set { this.Price = value; }
}
public int VR
{
get { return this.vr; }
set { this.vr = value; }
}
}
private static ArrayList mps;
static void mp3()
{
mp3players mp1 = new mp3players();
mp1.id = 1;
mp1.make = "GET technologies .inc";
mp1.model = "HF 410 ";
mp1.mbsize = 4096;
mp1.price = 129.95;
mp1.VR = 500;
mp3players mp2 = new mp3players();
mp2.id = 2;
mp2.make = "Far & Loud";
mp2.model = "XM 600 ";
mp2.mbsize = 8192;
mp2.price = 224.95;
mp2.VR = 500;
mp3players mp3 = new mp3players();
mp3.id = 3;
mp3.make = "Innotivative";
mp3.model = "Z3 ";
mp3.mbsize = 512;
mp3.price = 79.95;
mp3.VR = 500;
mp3players mp4 = new mp3players();
mp4.id = 4;
mp4.make = "Resistance S.A.";
mp4.model = "3001 ";
mp4.mbsize = 4096;
mp4.price = 124.95;
mp4.VR = 500;
mp3players mp5 = new mp3players();
mp5.id = 5;
mp5.make = "CBA";
mp5.model = "NXT volume ";
mp5.mbsize = 2048;
mp5.price = 159.05;
mp5.VR = 500;
mps = new ArrayList();
mps.Add(mp1);
mps.Add(mp2);
mps.Add(mp3);
mps.Add(mp4);
mps.Add(mp5);
}
static void mutteer()
{
int i = 1;
int a;
startloop:
while (i == 1)
{
Console.WriteLine("Wat is het Id van de mp3 speler?");
try
{
a = Convert.ToInt16(Console.ReadLine());
}
catch
{
Console.WriteLine("Dat is geen nummer waarde!");
goto startloop;
}
if (a == 1)
{
Console.WriteLine("Wat is het nieuwe voorraad");
try
{
你可以看到我在这里写的vr显然不起作用, 我需要使用这个集合并在我的理解中到达这里,但我如何得到一个get并设置使用它?
VR = Convert.ToInt32(Console.ReadLine());
i = 2;
}
catch
{
Console.WriteLine("Dat is geen nummer waarde!");
goto startloop;
}
}
}
}