CheckBoxListc#
DropDownMenuList数组
容器控件安全
Panel数据结构
PlaceHolderide
Calendar控件函数
viewState记住控件的状态布局
数据结构spa
数组code
string[] roles=new string[2]; roles[0]="Administrators"; roles[1]="ContentManagers";
数组的增加orm
string[] tempRoles=new string[3];//建立新的数组 Array.Copy(roles,tempRoles,roles.Length);//复制原数组中的元素 roles=tempRoles; roles[2]="Members";
集合
collection
ArrayList
ArrayList roles=new ArrayList(); roles.Add("A"); roles.Add("B"); roles.Add("C");
ArrayList可能会出现放入多个种类的对象,而后致使问题(不当心存入了一个dropdownList的控件也不会报错,可是取出时使用的时候可能会出问题)。这个时候能够使用范型,达到类型安全的目的
List<string> roles=new List<string>(); roles.Add("A"); roles.Add("B"); roles.Add("C"); List<int> myList=new List<int> {1,2,3,4,5};
算术运算符
+-*/%
逻辑运算
& 且,两个条件都知足时才返回true
| 或,两个条件至少知足其中一个时才返回true
&& 短路逻辑且,第一个知足时不会计算后面的内容
|| 短路逻辑或,第一个知足时不会计算后面的内容
类和属性
只读ReadOnly
省略设置器的代码就能够了,省略setter
自动ID类的
只写
密码类的
省略获取器的代码就能够
构造函数和对象初始化器
Person myPerson=new Person() {FirstName="Tom",LastName="Red"};
继承
System.Object 是.NET中全部其余数据类型的父类型。
C#重写父类的方法
public override string ToString() { return FullName+",birthday ="+_dateOfBirth.ToShortDateString(); }
public 全部类能够访问
protected 内部或者继承类能够访问
internal 程序集内能够访问
private 内部或者成员能够访问
事件驱动
<asp:Button ID="Button1" runat="server" Text="Button" onClick="Button1_Click" />
母版页面技术
定义PlaceHolder来肯定母版页面占的区域
master,在内容页面中加入
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.Master" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="CSSDemo.WebForm3" %> <asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server"> <asp:ListBox ID="ListBox1" runat="server"> <asp:ListItem>C#</asp:ListItem> <asp:ListItem>VB</asp:ListItem> <asp:ListItem>CSS</asp:ListItem> </asp:ListBox> </asp:Content>