📄 classproperties.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 + -