Skip to content

Instantly share code, notes, and snippets.

@gislig
Created May 10, 2018 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gislig/073ea54ffbbc8371ebd09bd1882ab8c9 to your computer and use it in GitHub Desktop.
Save gislig/073ea54ffbbc8371ebd09bd1882ab8c9 to your computer and use it in GitHub Desktop.
#The C# Code starts with @ sign and ends with @ sign.
$CSharpCode = @"
public class ExampleCSharp
{
public string ReturnTheString(string returnString)
{
string Combine = "Your awesome text is : " + returnString;
return Combine;
}
}
"@
#Add the C# code as definition
Add-Type -TypeDefinition $CSharpCode
#Example is the public class
$ExampleCSharpCode = New-Object -TypeName ExampleCSharp
#Run the public string ReturnString to get the results
$ExampleCSharpCode.ReturnTheString("Hello World")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment