C # Global Functions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi ,

I created a class call GlobalVar in global module

public class GlobalVar
{
public string str1
public string str2
}

how can I set it to my ascx text box ?
 
The sample you have will require you to create an instance of the GlobalVar
class in order to use the str1 and str1 members. You probably want to look
into static classes and members in order to make it "global" in terms of not
needing to create an instance of the class in order to use it.
 
Hi ,

This is the first time I use C#. Then I should add str1 and str2 into a
global module and use it right ? Can provide me some guidance on how to do
that ?
 
Travis,

There really isnt a "global" module in C# like there is in VB. The static
keyword gives you a similar type of behavior by allowing you to access
members of a class without creating an instance of it first. This will
allow you to call methods or variables from anywhere in your application
without having a variable of the class type first (ie. you do not need to
create an instance of the class to access it's members.)

You should take a look at the MSDN help on "static" and it should get you on
your way. It is pretty easy once you see an example or two of it.
 
Back
Top