static void Main(string[] args) { mylist <int> list = new mylist <int>(); //打印列表元素 for (int x = 0; x < 10; x++) { list.Add(x); } list.ForEach(x => Console.WriteLine(x)); //求和 int sum = 0; list.ForEach(delegate(int x) { sum += x; }); //求最大值 int max = 0; list.ForEach(delegate(int x) { max = max >= x ? max : x; }); //求最小值 int min = 0; list.ForEach(delegate(int x) { min = min <= x ? min : x; }); Console.WriteLine(sum); Console.WriteLine(max); Console.WriteLine(min); Console.Read(); }
public IHttpActionResult Putmylist(int id, mylist mylist) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mylist.Id) { return(BadRequest()); } db.Entry(mylist).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!mylistExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getmylist(int id) { mylist mylist = db.mylists.Find(id); if (mylist == null) { return(NotFound()); } return(Ok(mylist)); }
public IHttpActionResult Postmylist(mylist mylist) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.mylists.Add(mylist); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = mylist.Id }, mylist)); }
static void Main(string[] args) { mygeneric1 <int> .AddandPrint(100, 200); //这里<int>就是具体类型 mylist <string> Mylist = new mylist <string>("first"); //这里开始是第二个的调用 Mylist.Append("second"); mylist <int> Mylist2 = new mylist <int>(12); Mylist2.Append(1234); Console.WriteLine(Mylist2.ToString()); Console.ReadKey(); }
public IHttpActionResult Deletemylist(int id) { mylist mylist = db.mylists.Find(id); if (mylist == null) { return(NotFound()); } db.mylists.Remove(mylist); db.SaveChanges(); return(Ok(mylist)); }
public IActionResult UsingModelCalc() { Random rand = new Random(); int value1 = rand.Next(0, 10); int value2 = rand.Next(0, 10); int add = value1 + value2; int sub = value1 - value2; int mult = value1 * value2; double div = (double)value1 / (double)value2; mylist l = new mylist(add, sub, mult, div, value1, value2); if (value2 != 0) { return(View(l)); } else { return(View("ZeroErrorCalc")); } }
public void paint() { main = this.Owner as Form1; list = new mylist(); current = null; list._head = null; list._current = null; switch (mode) { case 1: for (int i = 0; i < main.dataGridView1.Rows.Count; i++) { bool nice = true; if (list._head != null) { current = list._head; while (current != null) { if (current.Faq == main.dataGridView1.Rows[i].Cells[3].Value.ToString()) { nice = false; if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { current.Bad++; } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { current.Good++; } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { current.Nice++; } } current = current.Next; } } else { if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { list.first(1, 0, 0, main.dataGridView1.Rows[i].Cells[3].Value.ToString(), "", ""); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { list.first(0, 1, 0, main.dataGridView1.Rows[i].Cells[3].Value.ToString(), "", ""); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { list.first(0, 0, 1, main.dataGridView1.Rows[i].Cells[3].Value.ToString(), "", ""); } else { list.first(0, 0, 0, main.dataGridView1.Rows[i].Cells[3].Value.ToString(), "", ""); } nice = false; } //MessageBox.Show(dataGridView1.Rows[i].Cells[1].Value.ToString().Substring(5, 2) + " - " + month[int.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString().Substring(5, 2))-1]); if (nice) { if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { list.first(1, 0, 0, main.dataGridView1.Rows[i].Cells[3].Value.ToString(), "", ""); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { list.first(0, 1, 0, main.dataGridView1.Rows[i].Cells[3].Value.ToString(), "", ""); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { list.first(0, 0, 1, main.dataGridView1.Rows[i].Cells[3].Value.ToString(), "", ""); } else { list.first(0, 0, 0, main.dataGridView1.Rows[i].Cells[3].Value.ToString(), "", ""); } } } int[] masX = new int[cnt]; int[] masG = new int[cnt]; int[] masN = new int[cnt]; string[] masY = new string[cnt]; current = list._head; for (int i = 0; i < cnt; ++i) { masX[i] = current.Bad; masY[i] = current.Faq; masG[i] = current.Good; masN[i] = current.Nice; current = current.Next; } chart1.Series[0].Points.Clear(); chart1.Series[1].Points.Clear(); chart1.Series[2].Points.Clear(); chart1.DataBind(); this.chart1.Series[1].EmptyPointStyle.IsValueShownAsLabel = false; for (int i = 0; i < cnt; i++) { this.chart1.Series[0].Points.AddXY(masY[i], masX[i]); this.chart1.Series[1].Points.AddXY(masY[i], masG[i]); this.chart1.Series[2].Points.AddXY(masY[i], masN[i]); } break; case 2: for (int j = 0; j < main.dataGridView1.ColumnCount; j++) { if (main.dataGridView1.Columns[j].HeaderText == "Курс") { main.dataGridView1.Sort(main.dataGridView1.Columns[j], ListSortDirection.Ascending); } } for (int i = 0; i < main.dataGridView1.Rows.Count; i++) { bool nice = true; if (list._head != null) { current = list._head; while (current != null) { if (current.Kurs == main.dataGridView1.Rows[i].Cells[5].Value.ToString()) { nice = false; if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { current.Bad++; } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { current.Good++; } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { current.Nice++; } } current = current.Next; } } else { if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { list.first(1, 0, 0, "", main.dataGridView1.Rows[i].Cells[5].Value.ToString(), ""); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { list.first(0, 1, 0, "", main.dataGridView1.Rows[i].Cells[5].Value.ToString(), ""); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { list.first(0, 0, 1, "", main.dataGridView1.Rows[i].Cells[5].Value.ToString(), ""); } else { list.first(0, 0, 0, "", main.dataGridView1.Rows[i].Cells[5].Value.ToString(), ""); } nice = false; } //MessageBox.Show(dataGridView1.Rows[i].Cells[1].Value.ToString().Substring(5, 2) + " - " + month[int.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString().Substring(5, 2))-1]); if (nice) { if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { list.first(1, 0, 0, "", main.dataGridView1.Rows[i].Cells[5].Value.ToString(), ""); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { list.first(0, 1, 0, "", main.dataGridView1.Rows[i].Cells[5].Value.ToString(), ""); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { list.first(0, 0, 1, "", main.dataGridView1.Rows[i].Cells[5].Value.ToString(), ""); } else { list.first(0, 0, 0, "", main.dataGridView1.Rows[i].Cells[5].Value.ToString(), ""); } } } int[] masAX = new int[cnt]; int[] masAG = new int[cnt]; int[] masAN = new int[cnt]; string[] masAY = new string[cnt]; current = list._head; for (int i = 0; i < cnt; ++i) { masAX[i] = current.Bad; masAY[i] = current.Kurs; masAG[i] = current.Good; masAN[i] = current.Nice; current = current.Next; } chart1.Series[0].Points.Clear(); chart1.Series[1].Points.Clear(); chart1.Series[2].Points.Clear(); chart1.DataBind(); this.chart1.Series[1].EmptyPointStyle.IsValueShownAsLabel = false; for (int i = 0; i < cnt; i++) { this.chart1.Series[0].Points.AddXY(masAY[i], masAX[i]); this.chart1.Series[1].Points.AddXY(masAY[i], masAG[i]); this.chart1.Series[2].Points.AddXY(masAY[i], masAN[i]); } break; case 3: for (int j = 0; j < main.dataGridView1.ColumnCount; j++) { if (main.dataGridView1.Columns[j].HeaderText == "Год поступления") { main.dataGridView1.Sort(main.dataGridView1.Columns[j], ListSortDirection.Ascending); } } for (int i = 0; i < main.dataGridView1.Rows.Count; i++) { bool nice = true; if (list._head != null) { current = list._head; while (current != null) { if (current.God == main.dataGridView1.Rows[i].Cells[8].Value.ToString()) { nice = false; if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { current.Bad++; } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { current.Good++; } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { current.Nice++; } } current = current.Next; } } else { if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { list.first(1, 0, 0, "", "", main.dataGridView1.Rows[i].Cells[8].Value.ToString()); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { list.first(0, 1, 0, "", "", main.dataGridView1.Rows[i].Cells[8].Value.ToString()); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { list.first(0, 0, 1, "", "", main.dataGridView1.Rows[i].Cells[8].Value.ToString()); } else { list.first(0, 0, 0, "", "", main.dataGridView1.Rows[i].Cells[8].Value.ToString()); } nice = false; } //MessageBox.Show(dataGridView1.Rows[i].Cells[1].Value.ToString().Substring(5, 2) + " - " + month[int.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString().Substring(5, 2))-1]); if (nice) { if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 61) { list.first(1, 0, 0, "", "", main.dataGridView1.Rows[i].Cells[8].Value.ToString()); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 76 && int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) < 90) { list.first(0, 1, 0, "", "", main.dataGridView1.Rows[i].Cells[8].Value.ToString()); } else if (int.Parse(main.dataGridView1.Rows[i].Cells[7].Value.ToString()) >= 90) { list.first(0, 0, 1, "", "", main.dataGridView1.Rows[i].Cells[8].Value.ToString()); } else { list.first(0, 0, 0, "", "", main.dataGridView1.Rows[i].Cells[8].Value.ToString()); } } } int summa = 0; int[] xmasX = new int[2]; string[] xmasY = { "2018", "2019" }; current = list._head; for (int i = 0; i < cnt; i++) { summa += current.Bad; current = current.Next; } for (int i = 0; i < 2; i++) { if (i > 0) { summa += xmasX[i - 1]; } xmasX[i] = summa / (cnt + i); if (summa % (cnt + i) > 4) { xmasX[i]++; } } int[] masBX = new int[cnt]; string[] masBY = new string[cnt]; current = list._head; for (int i = 0; i < cnt; ++i) { masBX[i] = current.Bad; masBY[i] = current.God; current = current.Next; } chart1.Series[0].Points.Clear(); chart1.Series[1].Points.Clear(); chart1.Series[2].Points.Clear(); chart1.DataBind(); this.chart1.Series[1].EmptyPointStyle.IsValueShownAsLabel = false; for (int i = 0; i < cnt; i++) { this.chart1.Series[0].Points.AddXY(masBY[i], masBX[i]); } for (int i = 0; i < 2; i++) { this.chart1.Series[0].Points.AddXY(xmasY[i], xmasX[i]); } break; } }