c#打印程序原码_C#程序打印新行

c#打印程序原码

C#打印新行 (C# printing a new line)

To print a new line within the message while printing it on the console, we can use following methods,

要在控制台上打印消息时在消息中打印新行,我们可以使用以下方法,

  • Using \n – prints new line

    使用\ n –打印新行

  • Using \x0A or \xA (ASCII literal of \n) – prints new line

    使用\ x0A或\ xA (\ n的ASCII文字)–打印新行

  • Console.WriteLine() – prints new line, if we write any message in the method – it will print new line after the message, if we do not write any message – it will print a new line only.

    Console.WriteLine() –如果在方法中写入任何消息,则打印新行–如果在消息中不写入任何消息,则它将在消息后打印新行–仅打印新行。

C#代码以打印新行 (C# code to print new line )

In the below example – we are printing new lines between the messages or/and after the message.

在下面的示例中,我们在消息之间或消息之后和之后打印新行。

// C# program to print a new line
using System;
using System.IO;
using System.Text;

namespace IncludeHelp
{
    class Test
    {
        // Main Method 
        static void Main(string[] args)
        {
            //using \n
            Console.WriteLine("Hello\nWorld");
            //using \x0A
            Console.WriteLine("Hello\x0AWorld");
            Console.WriteLine();

            Console.WriteLine("end of the program");

            //hit ENTER to exit the program
            Console.ReadLine();
        }
    }
}

Output

输出量

Hello
World
Hello
World

end of the program


翻译自: https://www.includehelp.com/dot-net/print-a-new-line-example-in-c-sharp.aspx

c#打印程序原码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值