传智播客.NET基础提高视频(2011新版)-29结构.zip
有讲到- using System;
- namespace test29
- {
- /// <summary>
- /// Program类
- /// </summary>
- internal class Program
- {
- public struct MyColor
- {
- public int Red;
- public int Green;
- public int Blue;
- }
- /// <summary>
- /// Main
- /// </summary>
- /// <param name="args"></param>
- private static void Main(string[] args)
- {
- //题目: 定义一个结构叫MyColor,有三个成员,分别为
- //red,green,blue
- //声明一个MyColor类型的变量,并对其成员赋值
- //使MyColor可以表示成一个红色
- MyColor oneMyColor;
- oneMyColor.Red = 255;
- oneMyColor.Green = 0;
- oneMyColor.Blue = 0;
- Console.WriteLine("红色: Red[{0}] Green[{1}] Blue[{2}]", oneMyColor.Red, oneMyColor.Green, oneMyColor.Blue);
- Console.ReadKey();
- }
- }
- }
复制代码 就是说: #ff0000
|