2017-2-18 net 輸入輸出語句

來源:互聯網
上載者:User

標籤:adl   name   年齡   wirte   資料類型   輸出   --   log   語句   

控制台程式的建立,輸出,輸入語句,定義變數,變數賦值,值覆蓋,值拼接,值列印
兩種資料類型,整形類型轉換

知識點:

1.輸出語句 Console.WriteLine("");游標換行    Console.Write("");游標在同行

輸入語句 Console.ReadLine("");游標換行     Console.Read("");游標在同行

2.變數的定義和賦值  值連結

string 字串   int整型   值連結  +  

string a = "今天天氣不錯";兩個string類型進行“+”操作,結果是:拼接

 int b = 1 ;整型可以執行“+-*/”操作,結果是數學運算

3.字串類型轉換成整型

string a = "你好";

int b = int.Parse(a);

課後練習:

練習題1:
“請輸入您的姓名:”同一行出現游標,等待使用者輸入
“請輸入您的性別:”游標,等待使用者輸入
“請輸入您的年齡:”同上
“請輸入您的身高:”同上
“請輸入您的體重:”同上
“--------------------華麗的分割線-----------------------”
xxx你好!您的性別是“男”,您的年齡是“18”,您的身高是“180”,您的體重是“180”。

練習題2:
您的身高和體重的和是“360”。

Console.Write("請輸入您的姓名:");string name = Console.ReadLine();Console.Write("請輸入您的性別:");string sex = Console.ReadLine();Console.Write("請輸入您的年齡:");string age = Console.ReadLine();Console.Wirte("請輸入您的身高:");srting a = Console.ReadLine();int height = int.Parse(a);Console.Write("請輸入您的體重:");string b = Console.ReadLine();int weight = int.Parse(b);Console.WriteLine("--------------華麗的分割線-----------------------");Console.WriteLine(name+"你好!您的性別是“"+sex+””,“+“您的年齡是“”+age+””,“+”您的體重是”“+height+"","+"您的體重是“"+weight+"”。");int sum = height+weight;Console.WriteLine("您的身高和體重是“"+sum+"’。");Console.WriteLine();

 

2017-2-18 net 輸入輸出語句

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.