本帖最后由 许庭洲 于 2012-11-4 21:03 编辑
使用Console.Write和Console.WriteLine
创建一个Windows控制台程序ConsoleOutput。其中主函数代码如下。
static void Main(string[] args)
{
bool myBool = true;
int myInt = 15;
double myDouble = 6.3;
char myChar = 'A';
string myString = "Hello";
char[] myCharArray = { 'a', 'b', 'c' }; //使用Console.Write输出
Console.Write(myBool);
Console.Write(" ");
Console.Write(myInt);
Console.Write(" ");
Console.Write(myDouble);
Console.Write(" ");
Console.Write(myChar);
Console.Write(" ");
Console.Write(myString);
Console.Write(" ");
Console.Write(myCharArray);
Console.Write(" ");
//使用Console.WriteLine输出
Console.WriteLine(myBool);
Console.WriteLine(myInt);
Console.WriteLine(myDouble);
Console.WriteLine(myChar);
Console.WriteLine(myString);
Console.WriteLine(myCharArray); //输出常量
Console.WriteLine(true);
Console.WriteLine(15);
Console.WriteLine(6.3);
Console.WriteLine('A');
Console.WriteLine("Hello");
Console.WriteLine(new char[] { 'a', 'b', 'c' });
}
|