// 先宣告再賦值
string strs = new
string[3];
int arr = new
int[3];
strs[0] == null
// true,預設為null
arr[0] // 0,預設為0
strs = ; // 報錯,不能這樣賦值
// 宣告並初始化,都正確
string strs = new
string[3];
string strs = new
string;
string strs = ;
// 引用型別,指向同一記憶體位址
string temp = strs;
temp[0] = "temp";
strs[0] // "temp"
console.writeline(" is .", "this", "a", "test");
// this is a test.
// 順序對應
console.writeline(" is .", "this", "a", "test");
// test is a a.
"" == string.empty; // true
string.isnullorempty(string.empty); // true
string.isnullorempty(null); // true
datetime dt = datetime.now;
// 月和天都不帶0,從1開始,7月16日
dt.year
dt.month // 7
dt.day // 16
dt.hour // 14,24小時制
dt.minute
dt.second
dt.millisecond
datetime dt = new datetime(2018, 7, 7, 7, 7, 7, 7);
// 注意不足10的情況,是否帶0
dt.tostring(); // 2018/7/7 7:07:07
dt.tolongdatestring() // 2023年7月7日
dt.toshortdatestring() // 2018/7/7
dt.tolongtimestring() // 7:07:07
dt.toshorttimestring() // 7:07
// h表示24h制,h表示12小時制
dt.tostring("yyyy-mm-dd hh:mm:ss"); // 2018-07-07 07:07:07
dt.tostring("y-m-d h:m:s"); // 18-7-7 7:7:7
// y、d、s不會格式化,其他字元對應輸出
dt.tostring("y-d-s s/d/y"); // y-d-s 7/7/18
C 基礎語法
最近開始學習c 程式語言,以前一直使用c c 也只是用到了一些最簡單基礎的用法。為了方便學習,將學習過程中c 語言與c c 不同或不熟悉之處記錄下來,以便日後隨時檢視。本人是通過閱讀 c 入門經典 第6版 學習c 在閱讀過程中隨手作如下記錄。變數在使用之前必須對其進行宣告和初始化。switch每個分...
C 基礎語法
簡介 c語句是面向結構的語言,c 是物件導向的語言,c 從根本上已經發生質飛躍,並對c進行豐富的擴充套件。c是c 的子集,所以大部c語言程式都可以不加修改的拿到c 下使用。c 不完全同於c語言,c語言,可以完全植入c 檔案 變數,指標,變數,迴圈,記憶體等 c 不完全相容c c 語言函式名是不能重名...
C 基礎語法
字段,屬性,方法,委託,事件.索引器,建構函式,析構函式.訪問修飾符 b 字段 b 欄位是被視為類的一部分的物件的例項,通常用於儲存類資料。例如,日曆類可能具有乙個包含當前日期的字段。可以選擇將字段宣告為 static。這使得呼叫方在任何時候都能使用字段,即使類沒有任何例項。可以將字段宣告為 rea...