⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classproperties.cs

📁 这是《ASP.NET编程实作教程》一书中的源文件 如果有此书的朋友不防下载过来参考
💻 CS
字号:
using System;
using System.Web;
using System.Web.UI;

namespace myControl {
	
    //类myFontStyle用于保存字体的信息
    public class myFontStyle {
 
    //私有变量_fontSzie,字体的大小
    private int     _fontSize;
    //私有变量_fontColor,字体的颜色
    private String  _fontColor;

    //类的构造函数
    public myFontStyle(int size, String color) {
         this.fontSize = size;
         this.fontColor = color;
    }
    
    //fontColor属性
    public String fontColor {
         get {
              return _fontColor;
          }
         set {
              _fontColor = value;
          }
     }
     
     //fontSize属性
     public int fontSize {
          get {
              return _fontSize;
          }
          set {
              _fontSize = value;
          }
        }    
    }
    
    //类ClassProperties定义控件
    public class ClassProperties : Control {
       
       //私有变量_myFont,是myFontStyle的实例
       private myFontStyle _myFont  = new myFontStyle(4, "blue");
       
       //属性myFont,用于控制字体显示效果
       public myFontStyle myFont {
           get {
              return _myFont;
           }
       }

       protected override void Render(HtmlTextWriter output) {
          output.Write("<font size="+ myFont.fontSize);
          output.Write(" color='" + myFont.fontColor +"'>"+"HelloWorld"+"</font>");
       }
    }    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -