C# 學習筆記 part 9 教你使用 if else if else 多層判斷,範例在 Windows Forms 窗體中執行

C# 入門 教學 9 教你使用 if else if else 多層判斷式,配合 Windows Forms 視窗應用程式

C# 或其他程式語言,都會學到 if 判斷式

if statements 是翻 if 陳述式,或是 if 語句

額...好吧,反正知道意思就好,是用來判斷東西,是否繼續向下執行...

大致上,會用在

1、字串比對是否一樣

2、變數內的值,比大小

3、布林,做旗標,或當開關用

如果你未安裝 Visual Studio 開發套件,參考 C# 學習,教你下載安裝 Visual Studio Community

卡在命名問題,參考 C# 學習 part 3 卡在第一關,命名問題...只能借助 Goole 翻譯

回顧上一篇,參考 C# 學習,教你使用 if 單層判斷,教你使用 if else if else 多層判斷


教你使用 if else if else 多層判斷式,配合 Windows Forms 視窗應用程式

Form1.cs [設計]

拉出那3個物件




然後 button1 上面點擊2下,到 Form1.cs




到 button1_Click 方法,打入如圖代碼






結果







Convert 上方按下 F1 鍵,可以到 MSDN 幫助文檔,查看用法

字串轉整數,就需要用到 Convert 這個物件




此篇文章之圖文教學,如果還不太明白,請至下方連結,查看 youtube 視頻解說

視頻解說之第一部分 https://www.youtube.com/watch?v=bgRKPjvkqEc

謝謝大家,抽空觀看,files備份檔名 csharp00009


後續文章 C# part 10 教你使用欄位、屬性,還有屬性的簡易寫法,及欄位、屬性二者差異


C# tutorial 9 Show you how to use if statements on Windows Forms

沒有留言:

發佈留言

由於一直被灌水, 因此您發表留言之後, 需要等待博客主的審核, 才會公開您的留言, 所以請不要重複的留言
Hello my friend, I have no money, My blog is super chill, Please do not screw me up in the replies at the bottom of the article, thanks a lot