public partial class Form1 : Form
    {
        //自定义的变量,用来记录当前选择的图形
        Style style = Style.Line;//Style这里提示错误,
        
 ……
   }编译背景:
我是在以前的书上看到的一个例子
是C#2.0的
vs2010错误提示:
错误1 未能找到类型或命名空间名称“Style”(是否缺少 using 指令或程序集引用?)已有命名空间:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows ;

解决方案 »

  1.   

    using System.Web.UI.WebControls;得引入这个命名空间
      

  2.   

    用对象浏览器查了下,没有单独的Style类;
    从LZ的注释来看,Style 我估计是自定义的一个枚举,像这样的
    enum Style {
            Line,Circle,Rectangle };
      

  3.   

    web中可以这样用 Style style = new Style();
     style.BackColor = Color.Blue;
     this.Header.StyleSheet.CreateStyleRule(style, null, "body");设置样式的。
      

  4.   

    不管是winform,webform都可以这样 Style s = new Style();
     s.BackColor = Color.Red;
    在winform中,表示在类型的不同实例之间共享属性、资源和事件处理程序。
    在命名空间System.Windows下
    MSDN:http://msdn.microsoft.com/zh-cn/library/system.windows.style.aspx
    在webform中,表示 Web 服务器控件的样式。
    在命名空间System.Web.UI.WebControls下
    MSDN:http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.style.aspx