将我的Powershell脚本转换为c#Windows窗体

将我的Powershell脚本转换为c#Windows窗体,c#,powershell,C#,Powershell,您好,我正在尝试将我的Powershell脚本“转换”为Windows窗体,这样它看起来很好,而不是在命令行上 我的Powershell脚本: # Food selector for the week! #random Stuff mixed for every day. Enum RandomFood {#Add Food here: Pizza Quesedias Lasagne } Enum Meat {#Add Food here: Steak Beaf Chicken Cordon

您好,我正在尝试将我的Powershell脚本“转换”为Windows窗体,这样它看起来很好,而不是在命令行上

我的Powershell脚本:

# Food selector for the week!
#random Stuff mixed for every day.

Enum RandomFood
{#Add Food here:
Pizza
Quesedias
Lasagne
}

Enum Meat
{#Add Food here:
Steak
Beaf
Chicken
Cordonbleu
}

function Food {

Clear-Host
  $Foods =  [Enum]::GetValues([RandomFood]) | Get-Random -Count 6
  $Foods += [Enum]::GetValues([Meat]) | Get-Random -Count 1

$foodsOfWeek = $Foods | Get-Random -Count 7
Write-Host `n "Here is you'r List of Meals for this week :D" `n
foreach ($day in [Enum]::GetValues([DayOfWeek])) {
    ([string]$day).Substring(0, 3) + ': ' + $foodsOfWeek[[DayOfWeek]::$day]
}
}
问题是我对C#非常陌生,我在以下几点上苦苦挣扎:

  • 包含膳食的数组(我在哪里创建它?我可以再次使用Enum吗?)
  • 如何从两个数组中获取7个随机项
  • 然后如何将膳食输出到表单中的文本框
我有一个简单的文本框(
textbox1
),还有一个按钮,可以生成所有这些(
button1

这是我在vb中想到的:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FoodSceduleGenerator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            string[] arr1 = {"Pizza", "Quesedias","Lasagne"};
            textBox1.Text = arr1;


        }
但它不起作用,我不明白。。。我花了两个小时在谷歌上搜索,但实在找不到更多的信息

我正在尝试先输出整个阵列,然后才能继续


感谢您提供的任何帮助/提示继续

您的功能食品在哪里?您的意思是什么@SeMInside你的PowerShell脚本你有
功能食品
,你在哪里用c#实现它?我计划在按钮中这样做?当我按下按钮时,它会执行其中的代码,所以我会将函数放在其中。为什么不在PowerShell中构建windows窗体并将其连接到您已有的代码?