> For the complete documentation index, see [llms.txt](https://johch3n611u.gitbook.io/c50108/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://johch3n611u.gitbook.io/c50108/ju-li-cheng-bei/201901/untitled-4.md).

# 2019/0124/C#宣告、指定運算子

![](/files/-LWxHPOzFgpZZqUu6JEN)

![](/files/-LWxRgSYtj_nUfwHTKUS)

ASP.net \_ (開發架構)

### WebForm &#x20;

只能有一個，一定要有一個 form

利用GUI 圖形開發 從 ASP.net 去抓 CSS / JS 函式庫&#x20;

![](/files/-LWxULGZaEs7yehJhcV-)

物件導向 (站在巨人的肩膀上寫成式，統一規則的東西先寫好，直接用)

開發速度很快 但 網頁會變很大 而且功能較無變化

code-behind 後置程式碼 C# .cs 類似資料庫的感覺&#x20;

### MVC

## C\#

變數名稱原則 :&#x20;

開頭不可以是數字/特殊符號/保留字/指令，必須是英文或底線，同一支程式區塊內，名稱不可重複，大小寫視為不同。

變數名稱規則 :&#x20;

使用有意義名稱，匈牙利命名法 string strStudentNo = "1234568"、int intNumber : "12331"，避免忘記型態。

### 物件導向&#x20;

功能都會有個(參數值)

Response.Write ( )

物件.方法

人.走 ( )

鳥.飛 ( )

![](/files/-LWxnLiDRAQYOxR2X-le)

宣告(資料型態 變數名稱) 指定運算值 參數值

string字串 var ="Hello World!!"&#x20;

string字串 var = 123數值                        ( X )

string字串 var = "123"字串                      ( O )  &#x20;

&#x20;            &#x20;

string字串 var = "123"字串 ;     宣告時則被初始化

&#x20;                  var = "354"字串 ;     會跑最後一段

string字串  var=" " ;  或者不用打 =" "  給你一個記憶體值

var = "123"字串 ;     第一次被初始化&#x20;

var = "354"字串 ;  &#x20;

bool 布林值 true

int   //32bit整數 X進位代表1個位元能表示X個東西 ； 32位元 為2進位 是代表32個位數每個位數有2個表示方式，並且有正負號。

long  //64bit 正負整數

short //16bit 正負整數

byte //8it 只能表示正整數

精準度 = 小數 = 浮點數(小數點會動，高階數學) 123.679 = 12367.9 \* 10的負2次方。

### 指定運算子

a = 20

a = a + 10 ; //a=30

a += 10 ; //a=40

a -= 15 ; //a=25

a \*= 10 ; //a=250

a /= 25 ; //a=10

a = a+1 ; //a=11

a += 1 ; //a=12

a++; // a=13

兩邊型態不同照理來說不可運算

但c#自動進行了隱含轉換將數字轉為字串使之可相加

字串  + 數字

"a="+a&#x20;

瀏覽器顯示 a=13

溢位

減法會失去精準度，因為計算機科學中 並沒有減法 必須用二的補數去算

decimal 十進制運算

x%y 為取於數運算

隱含轉換的問題

Response.Write(a + "+" + b + "=" + (a + b));&#x20;

Response.Write(a + "-" + b + "=" + (a - b));

Response.Write(a + "*" + b + "=" + a\** b);

Response.Write(a + "/" + b + "=" + a / b);

Response.Write(a + "%" + b + "=" + a % b);

位元運算 ^ 不會有溢位問題


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://johch3n611u.gitbook.io/c50108/ju-li-cheng-bei/201901/untitled-4.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
