c# 读取资源中的字符串_从C#中的用户输入读取字符串

本文介绍了如何在C#中使用Console.ReadLine()方法从用户获取输入的字符串,包括方法的语法、可能遇到的异常类型以及一个简单的示例程序。
摘要由CSDN通过智能技术生成

c# 读取资源中的字符串

To read a string from the user in C#, we use ReadLine() method of Console class.

要使用C#从用户读取字符串 ,我们使用Console类的ReadLine()方法。

Syntax:

句法:

    public static string Console.ReadLine();

Here, we don't pass any parameter and this method returns a string (a next line of the characters) from the input stream or returns null if there is no line of characters in the input stream.

在这里,我们不传递任何参数,并且此方法从输入流返回一个字符串(下一行字符),或者如果输入流中没有任何行,则返回null 。

The method ReadLine() may returns following exceptions,

方法ReadLine()可能返回以下异常,

  • IOException: If there is an input/output exception is occurred.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值