C#程序演示Console.Write()和Console.WriteLine()的示例

Console.Write() and Console.WriteLine() methods are used to print the text (values) on the Console. Console.Write() prints only the text, while Console.WriteLine() prints a new line after the text.

Console.Write()Console.WriteLine()方法用于在控制台上打印文本(值)。 Console.Write()仅打印文本,而Console.WriteLine()在文本之后打印新行。

Read more: Difference between Console.WriteLine() and Console.Write() in C#

阅读更多: C#中的Console.WriteLine()和Console.Write()之间的区别

Example:

例:

// C# program to demonstrate example of 
// Console.Write() and Console.WriteLine()
using System;
using System.IO;
using System.Text;

namespace IncludeHelp
{
    class Test
    {
        // Main Method 
        static void Main(string[] args)
        {

            Console.WriteLine("This is line1"); 
            Console.WriteLine("This is line2");
            Console.Write("This is line3");
            Console.Write("This is line4");            
            
            //hit ENTER to exit the program
            Console.ReadLine();
        }
    }
}

Output

输出量

This is line1
This is line2
This is line3This is line4


翻译自: https://www.includehelp.com/dot-net/console-write-and-console-writeline-example-in-c-sharp.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值