Skip to content

Variables

sancalle edited this page Oct 14, 2022 · 4 revisions

Typescript

var variable: string = "this is a variable";

or

let variable: string = "this is a variable";

C#

In C# those are wrapped into a static class

namespace Codeverter
{
    public static class Helper
    {
        public static string Variable = "this is a variable";
    }
}

Supported types

string

public static string Variable = "this is a variable";

number

public static int Variable = 1;

bool

public static bool Variable = true;

array

public static int[] Numbers = new int[] { 1, 2, 3 };
public static string[] Animals = new string[] { "cat", "dog", "horse" };

datetime

public static DateTime Variable = new DateTime(); // original constant assignation as comment

reference

public static Variable Variable = null; // original constant assignation as comment

GO

package codeverter

var Variable string = "this is a variable"

Supported types

string

var Variable string = "this is a variable"

number

var Variable int = 1

bool

var Variable bool = true

array

var Numbers []int = []int{1, 2, 3}
var Animals []string = []string{"cat", "dog", "horse"}

datetime

var Variable time.Time = time.Now() // original constant assignation as comment

reference

var Variable Foo // original constant assignation as comment

Visual Basic

In C# those are wrapped into a static class

Namespace Codeverter
    Module Helper
        Dim variable As String = "THIS IS A CONSTANT"
    End Module
End Namespace

Supported types

string

Dim variable As String = "THIS IS A CONSTANT"

number

Dim variable As Integer = 1

bool

Dim variable As Boolean = true

array

Dim constant As Integer() = { 1, 2, 3 }
Dim  Animals As String() = { "cat", "dog", "horse" }

datetime

Dim constant As Date = new DateTime() 'new Date()

reference

Dim constant As Foo = New Foo() 'new Foo()

Type inference

Supported. For example:

Typescript

let variable = "this is a variable";

C#

public static string Variable = "this is a variable";

GO

var Variable string = "this is a variable"

Visual Basic

Dim variable As String = "this is a variable"