c# 中的标准输出与 console.write
stdout vs console.write in c#
我对 C#/编程非常陌生,作为一项学习练习,我完成了将文本更改为小写的在线挑战。挑战指定它必须 'print to stdout' 但我使用 Console.Writeline
完成了挑战
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lowercase
{
class Program
{
static void Main(string[] args)
{
using ( StreamReader reader = new StreamReader("TextFile1.txt"))
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
Console.WriteLine(line.ToLower());
}
Console.ReadLine();
}
}
}
}
stdout
只是输出到控制台的另一个名称(提交可以使用多种不同的语言)还是在线代码提交只是没有正确检查输出。我已经用谷歌搜索 'stdout c#' 但不完全理解结果。
在 C 和 C++ 等语言中,有一个名为 stdout
的全局变量,它是指向标准输出流的指针。因此,即使在 C 语言的上下文之外,stdout
也成为 "standard output stream" 的常用缩写。
现在,C# 有什么作用?让我们看看 the documentation of Console.WriteLine(强调我的):
Writes the specified string value, followed by the current line terminator, to the standard output stream.
所以,是的,Console.WriteLine
做的正是您需要做的。如果你需要直接引用标准输出流(提示:你通常不需要),你可以使用 Console.Out 属性.
我对 C#/编程非常陌生,作为一项学习练习,我完成了将文本更改为小写的在线挑战。挑战指定它必须 'print to stdout' 但我使用 Console.Writeline
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lowercase
{
class Program
{
static void Main(string[] args)
{
using ( StreamReader reader = new StreamReader("TextFile1.txt"))
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
Console.WriteLine(line.ToLower());
}
Console.ReadLine();
}
}
}
}
stdout
只是输出到控制台的另一个名称(提交可以使用多种不同的语言)还是在线代码提交只是没有正确检查输出。我已经用谷歌搜索 'stdout c#' 但不完全理解结果。
在 C 和 C++ 等语言中,有一个名为 stdout
的全局变量,它是指向标准输出流的指针。因此,即使在 C 语言的上下文之外,stdout
也成为 "standard output stream" 的常用缩写。
现在,C# 有什么作用?让我们看看 the documentation of Console.WriteLine(强调我的):
Writes the specified string value, followed by the current line terminator, to the standard output stream.
所以,是的,Console.WriteLine
做的正是您需要做的。如果你需要直接引用标准输出流(提示:你通常不需要),你可以使用 Console.Out 属性.