Skip to content

Instantly share code, notes, and snippets.

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 DanielAdeniji/295a544b81e8036a3c37425bcc81cc95 to your computer and use it in GitHub Desktop.
Save DanielAdeniji/295a544b81e8036a3c37425bcc81cc95 to your computer and use it in GitHub Desktop.
Calling Powershell function with commas
[string] $title;
[char] $ch;
[int] $len=0;
[string] $filler = "";
[boolean] $bCallFunctionWithComma = $false;
function repeatChar([char] $ch,[int] $n)
{
[String] $str = "";
$str = [String]::new( $ch, $n);
return ( $str);
}
$ch = '=';
$title = 'Head of the class';
$len = $title.length;
$bCallFunctionWithComma = $true;
#$bCallFunctionWithComma = $false;
if ($bCallFunctionWithComma -eq $true)
{
$filler = repeatChar( $ch, $len);
}
else
{
$filler = repeatChar -ch $ch -n $len;
}
Write-Host $title;
Write-Host $filler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment