Hey all ,,,,
basicly i come from a vb language to c# and i'm using couple of varables and constant that i'm using upon all my project so is there any way that i can set like a public variable that i can use every time i need or even a publicc method or something like that ??

Recommended Answers

All 3 Replies

The closest you can get would be a static class in C# with those variables as members. Place that class in a shared assembly (if your project uses more than one assembly) and you're good to go.

commented: thaks +0

Dear deceptikon ,
i'm new to C# so is there is any way that you can provide with an example snippet or with way to do it
and thanks in advance.

public static class Globals
{
    public static readonly string Foo = "DAFOO";
}

...

Console.WriteLine(Globals.Foo);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.