SDK for CodeConverter.net
function Method
{
if (1 -eq 2)
{
[int]$variable = 1;
}
elseif ("xyz" -eq (New-Object -TypeName Object))
{
[int]$variable = 2;
}
else
{
[int]$variable = 3;
}
}
void Method()
{
if (1 == 2)
{
int variable = 1;
}
else if ("xyz" == (new Object()))
{
int variable = 2;
}
else
{
int variable = 3;
}
}
function Method
{
[TimeZoneInfo]$timeZoneInfo = New-Object -TypeName TimeZoneInfo
[string]$variable = $timeZoneInfo.DisplayName
}
void Method()
{
TimeZoneInfo timeZoneInfo = new TimeZoneInfo();
string variable = timeZoneInfo.DisplayName;
}
function Method
{
[bool]$eq = 1 -eq 2
[bool]$notEq = 1 -ne 2
[bool]$or = 1 -eq 2 -or 2 -eq 1
[bool]$and = 1 -eq 2 -and 2 -eq 1
[bool]$gt = 1 -gt 2
[bool]$lt = 1 -lt 2
[bool]$ge = 1 -ge 2
[bool]$le = 1 -le 2
[int]$plus = 1 + 1
[int]$minus = 1 - 1
[int]$bor = 1 -bor 1
}
void Method()
{
bool eq = 1 == 2;
bool notEq = 1 != 2;
bool or = 1 == 2 || 2 == 1;
bool and = 1 == 2 && 2 == 1;
bool gt = 1 > 2;
bool lt = 1 < 2;
bool ge = 1 >= 2;
bool le = 1 <= 2;
int plus = 1 + 1;
int minus = 1 - 1;
int bor = 1 | 1;
}
function Method
{
Write-Host -Object "Hello, World!"
Write-Host "Hello, World!"
}
void Method()
{
Console.WriteLine("Hello, World!");
Console.WriteLine("Hello, World!");
}
function Method
{
param([string[]]$strings)
foreach($item in $strings)
{
[string]$str = $item
continue
}
}
void Method(String[] strings)
{
foreach (var item in strings)
{
string str = item;
continue;
}
}
function Method
{
[int]$i = 0
[int]$x = 1
switch ($i)
{
2 { $x = 2 }
3 { $x = 3 }
default { }
}
}
void Method()
{
int i = 0;
int x = 1;
switch (i)
{
case 2:
x = 2;
break;
case 3:
x = 3;
break;
default:
break;
}
}
function Method
{
[string[]]$arr = @("my","strings")
}
void Method()
{
string[] arr = new [] { "my", "strings" };
}
function Method()
{
Out-File -InputObject "My output test" -FilePath "supersecretfile.txt"
Out-File "supersecretfile.txt" -InputObject "My output test" -Append
}
void Method()
{
File.WriteAllText("supersecretfile.txt","My output test");
File.AppendAllText("supersecretfile.txt","My output test");
}
function Method
{
param([string]$argument, [int]$integer)
}
void Method(String argument, Int32 integer)
{
}
function Method
{
[int]$variable = 1
[string]$variable2 = "myString"
}
void Method()
{
int variable = 1;
string variable2 = "myString";
}
function Method
{
while($true)
{
break
}
}
void Method()
{
while (true)
{
break;
}
}
function Method
{
throw (New-Object -TypeName Exception -ArgumentList "Hey")
}
void Method()
{
throw (new Exception("Hey"));
}
function Method
{
return 1
}
void Method()
{
return 1;
}
function Method
{
New-Object -TypeName System.Object -ArgumentList $myVariable
}
void Method()
{
new System.Object(myVariable);
}
function Method
{
param([string]$str)
[string]$item = $str[3]
}
void Method(String str)
{
string item = str[3];
}
function Method
{
}
void Method()
{
}
function Method
{
try
{
$item = New-Object -TypeName object
}
catch [Exception]
{
$item = New-Object -TypeName object
}
catch
{
$item = New-Object -TypeName object
}
finally
{
$item = New-Object -TypeName object
}
}
void Method()
{
try
{
item = new object();
}
catch (Exception)
{
item = new object();
}
catch
{
item = new object();
}
finally
{
item = new object();
}
}
function Method
{
Start-Process -FilePath "notepad.exe" -ArgumentList "myText.txt"
Start-Process "notepad.exe" -ArgumentList "myText.txt"
}
void Method()
{
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "notepad.exe";
startInfo.Arguments = "myText.txt";
process.StartInfo = startInfo;
process.Start();
;
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "notepad.exe";
startInfo.Arguments = "myText.txt";
process.StartInfo = startInfo;
process.Start();
;
}
function Method()
{
[Guid]::New()
}
void Method()
{
Guid.New();
}
function Method
{
[int]$myInt = 1
[long]$myLong = [long]$myInt
}
void Method()
{
int myInt = 1;
long myLong = (long)myInt;
}
function Method
{
New-Object -TypeName System.Object
}
void Method()
{
new System.Object();
}
function Method
{
for([int]$i = 0; $i -lt 100; $i++)
{
[int]$t = $i
}
}
void Method()
{
for(int i = 0; i < 100; i++)
{
int t = i;
}
}