zoukankan      html  css  js  c++  java
  • foreach & Random

    using System;
    public class ForEachTest
    {
        public static void Main()
        {
            int odd=0;
            int eve=0;
            int length=100;
            int[] arr=new int[length];
            Random r = new Random();
            for(int i=0;i<length;i++)  //随机数赋值
            {
                arr[i]= r.Next();
            }    
            foreach(int tem in arr)  //foreach 举例
            {
                if(tem%2==0)
                    eve++;
                else
                    odd++;
            }
            Console.WriteLine("奇数"+odd+"");
            Console.WriteLine("偶数"+eve+"");
        }    
    }
     foreach (DataGridViewRow row in kDataGridView1.Rows)
                    {
                        switch(row.Cells["state"].Value.ToString())
                        {
                            case "0":
                                row.Cells["state"].Value = "未用";
                                break;
                            case "1":
                                row.Cells["state"].Value = "正常";
                                break;
                            case "2":
                                row.Cells["state"].Value = "停用";
                                break;
                            case "3":
                                row.Cells["state"].Value = "废弃";
                                break;
                            case "4":
                                row.Cells["state"].Value = "挂失";
                                break;
                            default:
                                row.Cells["state"].Value = " ";
                                break;
                        
                        }
                    }
  • 相关阅读:
    精准测试
    git 管理
    git
    代码覆盖率测试
    vue 前端视频
    jenkins
    go学习资料
    4-4 求自定类型元素的平均
    4-3 简单求和
    4-2 多项式求值
  • 原文地址:https://www.cnblogs.com/quke123/p/4101809.html
Copyright © 2011-2022 走看看