最近公司要求要學習開發window平台軟體..

可以選擇使用C#或MFC,

一個月內要有產出...

想了以後覺得MFC對菜不啦嘰的我來說進入障礙太高了...

還是選擇據說跟JAVA很像的C#...

選了以後發現不但要學C#還要學MPF...各種困難...

而且說像也不是真的完全一樣,還是有很多不同之處需要琢磨呀...

先把練習的筆記整理起來備用吧....

 


 
*關於字串的使用
 
(一)宣告字串變數:
string a="kelly";
 
(二)字串插補:
在字串前加上"$"符號,並用{}括住變數
Console.WriteLine($"Hello { aFriend}");
 
字串插補印出來的效果等同於
Console.WriteLine("Hello"+aFriend);
 
在整個字串中並不限制只能使用一個大括號
string firstFriend = "Maria";
string secondFriend = "Sage";
Console.WriteLine($"My friends are {firstFriend} and {secondFriend}");
 
(三)字串屬性:
Length=>字串長度
Console.WriteLine($"The name {firstFriend} has {firstFriend.Length} letters.");
Console.WriteLine($"The name {secondFriend} has {secondFriend.Length} letters.");
 
其他字串屬性可以查詢連結文件
 
字串的方法
 
 
*關於數字的使用
 
(一)int整數(可為正整數或負整數):
- 用於減法
* 用於乘法
/ 用於除法
% 取得餘數
 
數學運算的優先順序,乘法和除法的優先順序高於加法和減法。    
 
int 型別有最小和最大限制。 (java亦同)
int max = int.MaxValue;
int min = int.MinValue;
Console.WriteLine($"The range of integers is {min} to {max}");
 
 
(二)Double 雙精確度浮點數:
double a = 19;
double b = 23;
double c = 8;
double d = (a  + b) / c;
Console.WriteLine(d);
 
(三)decimal固定點型別:
decimal的範圍較小,但精確度較 double 來得高。 固定點這個詞代表小數點 (或二進位點) 不會移動。
 
double a = 1.0;
double b = 3.0;
Console.WriteLine(a / b);
 
 
decimal c = 1.0M;
decimal d = 3.0M;
Console.WriteLine(c / d);
M 尾碼乃是指示常數應使用 decimal 型別
 
 
文章標籤

muchone 發表在 痞客邦 留言(0) 人氣()