Right now i'm trying to convert my C# Code to an PowerShell Script.
My actual function in C# looks like this:
private static string ReplaceStringPartAt(string mainstring, int position, string replacement)
{
StringBuilder strBuilder = new StringBuilder(mainstring);
strBuilder.Remove(position, replacement.Length);
strBuilder.Insert(position, replacement);
return strBuilder.ToString();
}
And my PowerShell function like this:
function ReplaceStringPartAt($mainstring, $position, $replacement)
{
$strBuilder = New-Object System.Text.StringBuilder;
$strBuilder.AppendLine($mainstring)
$strBuilder.Remove($position, $replacement.Length);
$strBuilder.Insert($position, $replacement);
return $strBuilder.ToString();
}
But i alway get an [System.Text.StringBuilder] as return value.
What do i miss to make the function work again?