class="brush:csharp;gutter:true;"> Random r = new Random(); string str = ""; for (int i = 0; i < 5; i++) { int a= r.Next(0, 10); str += a;//将数字连接到一块 } Bitmap bm = new Bitmap(150, 90);//创建位图对象 Graphics g = Graphics.FromImage(bm);//在bm中重新画图 //创建字体跟颜色数组 string[] font = { "楷体", "黑体", "宋体", "斜体", "新宋体" }; Color[] colors = { Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.YellowGreen }; //开始画图 for (int i = 0; i < 5; i++) { Point p=new Point (i*20,0); g.DrawString(str[i].ToString(), new Font(font[i], 20, FontStyle.Bold), new SolidBrush(colors[i]), p); } pictureBox1.Image = bm;//将位图显示到picture上