- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 C# 交互式编译器 csi.exe
来运行 .csx
脚本。如何访问提供给我的脚本的任何命令行参数?
csi script.csx 2000
如果您不熟悉 csi.exe,这里是用法信息:
>csi /?
Microsoft (R) Visual C# Interactive Compiler version 1.3.1.60616
Copyright (C) Microsoft Corporation. All rights reserved.
Usage: csi [option] ... [script-file.csx] [script-argument] ...
Executes script-file.csx if specified, otherwise launches an interactive REPL (Read Eval Print Loop).
最佳答案
CSI 有一个 Args
global which parses out the arguments for you .在大多数情况下,这将为您提供所需的参数,就像您正在访问 argv
一样。在 C/C++ 程序中或 args
在 C# Main()
签名static void Main(string[] args)
.
Args
有一个类型 IList<string>
而不是 string[]
.所以你将使用 .Count
查找参数数量而不是 .Length
.
下面是一些示例用法:
#!/usr/bin/env csi
Console.WriteLine($"There are {Args.Count} args: {string.Join(", ", Args.Select(arg => $"“{arg}”"))}");
还有一些示例调用:
ohnob@DESKTOP-RC0QNSG MSYS ~/AppData/Local/Temp
$ ./blah.csx
There are 0 args:
ohnob@DESKTOP-RC0QNSG MSYS ~/AppData/Local/Temp
$ ./blah.csx hi, these are args.
There are 4 args: “hi,”, “these”, “are”, “args.”
ohnob@DESKTOP-RC0QNSG MSYS ~/AppData/Local/Temp
$ ./blah.csx 'hi, this is one arg.'
There are 1 args: “hi, this is one arg.”
关于c# - 如何访问 .csx 脚本中的命令行参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38529021/
我们如何创建另一个 run.csx 并在 Azure Function App 中将现有函数从一个 csx 文件调用到另一个文件? 最佳答案 您可以编写另一个文件,例如lib.csx 并通过主脚本文件
查看 Microsoft Edge homepage 的来源,页面的样式表加载为:- 进一步挖掘 style.csx 的源代码,该文件的语法类似于 scss,例如:- @mixin font-fac
我正在使用 C# 交互式编译器 csi.exe 来运行 .csx 脚本。如何访问提供给我的脚本的任何命令行参数? csi script.csx 2000 如果您不熟悉 csi.exe,这里是用法信息:
在 F# 中,使用预定义标识符 __SOURCE_DIRECTORY__ 相当容易 https://stackoverflow.com/a/4861029/2583080 但是,此标识符在 C# 脚本
我听说过 .cs 文件,但从未听说过 .csx files .谷歌搜索将我带到了 CSX 公司和其他不需要的机构。有人可以简要描述什么是 CSX 文件,以及 CSX 和 CS 之间的主要区别吗? 最佳
我正在尝试在 Visual Studio Code 中的本地主机上调试 Azure 函数 (CSX)。我可以附加调试器,但无法设置断点。我应该安装一些东西吗? 最佳答案 目前,VS Code 中不支持
我正在创建 template.json 以使用 ARM 模板部署我的 Function App。我知道我们可以这样做来在函数应用程序中创建一个函数: { "apiVer
我已将 NuGet 包包含在 Azure Function 应用程序中,我下载该应用程序以在 Visual Studio 中使用。我已将其添加到 project.json 中,但仍然收到“错误 CS0
是否可以制作可移植脚本? 我想编写一个脚本并从另一台计算机(具有相同操作系统)上的控制台/bat 文件触发它。我想这应该是这样的: SomeKindOfScriptCsExecutor.exe mys
是否可以制作可移植脚本? 我想编写一个脚本并从另一台计算机(具有相同操作系统)上的控制台/bat 文件触发它。我想这应该是这样的: SomeKindOfScriptCsExecutor.exe mys
每次我从我的项目中重置 C# 交互窗口时,是否可以告诉 Visual Studio 或 Roslyn 执行特定的代码脚本? 例如 - 我有一个带有绘图仪的表单,它显示了我正在处理的大部分数据。我希望每
我正在玩 ScriptCS (太棒了!)但我想不出如何在 .csx 脚本文件中定义扩展方法。 举个例子: using System.IO; public static class Extensions
我正在使用 AzureQueue 触发器模板,最好在本地计算机中编写函数,编译并执行它,然后部署,而不是在 Azure 门户中编写它。有什么办法可以做到吗? 谢谢! 最佳答案 克里斯, 答案是肯定的,
我的 MVC 4 应用程序已部署到 Azure。 Azure 项目包含一个 csx 文件夹。当我发布到 Azure 时,该文件夹中是否有任何内容不会自动重新创建?换句话说,该文件夹中是否有任何符合“源
我正在尝试编写一个需要使用 NuGet 包的 C# 交互式脚本 (.csx),但我一定是忽略了一些基本的东西,因为我无法让它工作。 我尝试添加一个引用包的 project.json,当我 nuget
我正在使用 Visual Studio 2015 Update 2。根据 csi.exe,有诸如“C# 脚本文件”之类的东西: Executes script-file.csx if specifie
我想使用 csx 查询 CosmosDB 集合以查看 Azure Functions 中是否已存在文档。 除了以下代码之外,我还对 cosmosDB 集合进行了隐式绑定(bind),以便能够创建新文档
最近我得到了其他开发人员用 C# 脚本(.csx)编写的 Azure 函数代码,我曾经使用 Visual Studio 编写 Azure 函数。 我喜欢 C# 脚本命令式绑定(bind),它使代码更简
我刚刚在 Azure 上创建了一个机器人服务,它看起来与我上次获得的完全不同。当时我得到了一堆 CSX 文件。现在它已经创建了一个看起来像完整的 ASP.NET 应用程序(参见屏幕截图)。 现在有多少
我目前正在学习新的 Microsoft 认证,Azure Functions 文档中的这段代码引起了我的注意 ( link ): The Azure Functions Tools provides
我是一名优秀的程序员,十分优秀!