何时使用 Powershell 与 C# 进行开发?

发布于 2024-10-02 18:25:15 字数 1429 浏览 6 评论 0原文

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

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

发布评论

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

评论(3

原谅过去的我 2024-10-09 18:25:15

1) PowerShell 适用于相对较小的明确定义的任务,特别是当您直接在命令行中编码时的临时一日任务和交互式任务。如果一项任务只需要几行 PowerShell 代码(并且您知道这一点,因为您对 PowerShell 足够了解!),那么启动完整的 C# 项目通常是大材小用。

2) C# 对于大型项目或性能至关重要的项目要好得多。对于任何可能需要调试和故障排除的项目来说,它都是更好的选择。

3)PowerShell和C#可以完美协同工作。互相调用是很容易的。 PowerShell 非常适合连接 .NET 组件。您可以使用 C# 实现复杂且性能关键的部分,然后使用 PowerShell 将这些部分组合并粘合在一起。

1) PowerShell is good for relatively small well defined tasks, especially ephemeral one-day tasks and interactive tasks when you are coding right in the command line. If a task requires just a few lines of PowerShell code (and you know that because you know PowerShell well enough!) then launching a full C# project is often overkill.

2) C# is much better for large projects or where performance is critical. It is better for any project that will presumably require debugging and troubleshooting.

3) PowerShell and C# can perfectly work together. It is easy to call one from another. PowerShell is good for connecting .NET components. You can implement your complex and performance critical pieces in C# and then combine and glue those pieces together with PowerShell.

佞臣 2024-10-09 18:25:15

很久以前(1997 年),当我在 Windows 构建实验室工作时,我被教导的规则是,如果代码满足这两个条件中的任何一个,则将其写入解释脚本中,否则将其写入编译代码中:

  1. 比代码有更多的开销(使用/include 行、函数声明等)
  2. 在代码再次运行之前有超过 10% 的机会发生更改

When I worked in the Windows build lab a LONG time ago (1997) the rule I was taught that if the code satisfies either of these two conditions write it in interpreted script, otherwise write it in compiled code:

  1. there's more overhead than code (using/include lines, function declaration, etc)
  2. there's a better than 10% chance that the code will change before it gets run again
最初的梦 2024-10-09 18:25:15

从基础设施的角度来看,Hyper-V 在虚拟化市场中变得越来越庞大,其市场份额增长每年都超过了 VMWare。关于 SCVMM 自动化,如果您想利用 VMM 功能来管理运行不同虚拟机管理程序的多个主机,VMM powershell 界面是唯一的选择。

From an infrastructure point of view, Hyper-V is getting huge in the virtualization market, it's outgrowing VMWare every year in terms of market share growth. Concerning SCVMM automation, if you want to leverage VMM functionality of managing multiple hosts running different hypervisors, VMM powershell interface is the only option.

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