Skip to content

Instantly share code, notes, and snippets.

@kemokemo
Created February 18, 2022 06:46
Show Gist options
  • Save kemokemo/3e5209d9bc7ffb5190d905cd754f3644 to your computer and use it in GitHub Desktop.
Save kemokemo/3e5209d9bc7ffb5190d905cd754f3644 to your computer and use it in GitHub Desktop.
PowerShellスクリプトからC#コードを使う例
using System;
public static class Speaker
{
public static void Say(string word)
{
char[] trimChars = {'/'};
word = word.TrimEnd(trimChars);
Console.WriteLine(word + "!");
}
}
param($word)
$assemblies = (
"System"
)
$src = Get-Content "say.cs" | Out-String
Add-Type -TypeDefinition $src -Language CSharp -ReferencedAssemblies $assemblies
[Speaker]::Say($word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment