gpt4 book ai didi

c# - 如何使用 txt 文件作为命令行参数?

转载 作者:行者123 更新时间:2023-11-30 13:59:40 24 4
gpt4 key购买 nike

我有一个这样的 .txt 文件:
6 4
1 2
2 3
3 4
4 5
1 2 4 5

如何在 C# 中将其用作命令行参数?

最佳答案

如果您打算提供您的程序数据 program.exe < data.txt ,这称为从标准输入读取。您可以通过 .NET 的 Console.OpenStandardInput 执行此操作与

new StreamReader(Console.OpenStandardInput())

或者,如果您希望程序运行 program.exe data.txt , 开始于

void Main(string[] args)
{
File.ReadLines(args[0])
}

关于c# - 如何使用 txt 文件作为命令行参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12770561/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com