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>