c# - That name doesn"t exist in the current context error -
c# - That name doesn"t exist in the current context error -
in public static void ammount()
error saying: "the name 'mps' not exist in current context" how prepare error?
struct mp3players{ private int id; private string make; private string model; private int mbsize; private double price; private int vr; public int id { { homecoming this.id; } set { this.id = value; } } public string create { { homecoming this.make; } set { this.make = value; } } public string model { { homecoming this.model; } set { this.model = value; } } public int mbsize { { homecoming this.mbsize; } set { this.mbsize = value; } } public double cost { { homecoming this.price; } set { this.price = value; } } public int vr { { homecoming this.vr; } set { this.vr = value; } } } public 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; arraylist mps = new arraylist(); mps.add(mp1); mps.add(mp2); mps.add(mp3); mps.add(mp4); mps.add(mp5); foreach (mp3players value in mps) { console.writeline("id: " + value.id); console.writeline("make: " + value.make); console.writeline("model: " + value.model); console.writeline("mbsize: " + value.mbsize); console.writeline("price: " + value.price); console.writeline(); } }
this error occurs.
i tried couple of ways did not find searching for.
public static void ammount() { foreach (mp3players value in mps) { console.writeline("id: " + value.id); console.writeline("model: " + value.model); console.writeline(); } }
i not in c#
explanation did wrong welcome!
public static void ammount() { foreach (mp3players value in mps) { console.writeline("id: " + value.id); console.writeline("model: " + value.model); console.writeline(); } }
this code has knowledge of mps
.
you add together parameter method public static void ammount()
looks public static void ammount(mp3players[] mps)
. prepare error cause another
you have pass mps method.
c# arraylist struct scope
Comments
Post a Comment