jaomello

When i program in VB i use module to use variables and the same function in all project... in this way don't change their values... but in C#, how can i do it




(Sorry, if my english is bad... I'm form Brazil)


Re: Visual C# Language I use module in VB what i can use in C#

Mark Dawson

Hi,

if you have variables you want to use throughout your project you can use a static class in C# which will allow you to define values to be used throughout your application.

i.e.

public static class Abcd

{

...

}

Mark.






Re: Visual C# Language I use module in VB what i can use in C#

Tanvir Huda

HI Jaomello

C# is more roboust object oriented language. So you have to rely on objects implementing your application.

The basic of this is class files.

So create a class file in your project.

When you need to refer to that class file, create an intance of the class file.

once you create the instance of the class you will be able to excess its public properties and methods directly. If you want the values of public properties remain same through out the project runtime declare the property as static as mentioned.

Hope that helps you.

Cheers

Shayer






Re: Visual C# Language I use module in VB what i can use in C#

David Anton

A VB module is (nearly) equivalent to a static sealed class.

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter






Re: Visual C# Language I use module in VB what i can use in C#

RizwanSharp

simply declare your class as static and use its members from anywhere in your probject without creating any object of it:

here is example os a static class:

public static class Employee

{

private static int salary;

private static string name;

public static int Salary

{ get return salary;}

{ set salary = value;}

public static string Name

{ get return name; }

{ set name = value; }

public static void SomeFunction()

{

////////

}

}

Now you can access any member of Employee using:

Employee.SomeFunction();

int employeeSalary = Employee.Salary;

etc....

I hope this will help.

Best Regards,

Rizwan aka RizwanSharp






Re: Visual C# Language I use module in VB what i can use in C#

jaomello

Thanks a lot, guys....