为什么即使将用户输入存储在字符串类型?ps中时,为什么在Console.Readline()方法下获得红线。使用var删除红线?

发布于 2025-01-26 09:52:07 字数 320 浏览 2 评论 0原文

Console.WriteLine("Enter arguments");
string input = Console.ReadLine();// red line under Console.ReadLine
Console.WriteLine("Arguments at run-time  " + input);

/* 我想通过我的控制台。writeline方法在字符串中显示用户输入,并且我知道by-default它是在字符串类型中显示的,那么为什么在使用字符串时在console中获得红色线。在使用字符串时,而不是在var Type中存储时,请读取呢?谢谢! */

Console.WriteLine("Enter arguments");
string input = Console.ReadLine();// red line under Console.ReadLine
Console.WriteLine("Arguments at run-time  " + input);

/*
I want to show the user input in string through my Console.WriteLine method and I know by-default it is in string type so why am getting red line under Console.ReadLine when using string and not when store in var type? Thanks! */

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神妖 2025-02-02 09:52:07

Console.Readline();函数可以返回null值,而IDE表示为安全。使用字符串?

The Console.ReadLine(); function can return a null value and the IDE indicates that for safety. Use string?.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文