主控台是在DOS視窗執行的一種應用程式,以下簡單的介紹,讓大家對程式的運作能有基礎的認知.
新增專案後,開啟主控台應用程式,輸入名稱後開始撰寫程式碼,以下為範例:
開啟專案後,系統會建立一個基本的框架如下.
using System;
using System.Collections.Generic;
using System.Text;
namespace name//此為檔案名稱
{
class Program
{
static void Main(string[] args)
{
}
}
}
程式碼的輸入:
static void Main(string[] args)
{
//在此輸入程式碼
}
程式碼:
//令資料成員aˋb為整數,c為字串
int a,b;
String c;
Console.Write("Please input a number:");
c=Console.ReadLine();
a=int.Parse(c);
b=a*a;
Console.Write("The Square is:");
Console.WriteLine("b");
沒有留言:
張貼留言