473,509 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C # Global Functions

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 ?

--
Travis Tan
Feb 20 '06 #1
3 1507
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.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Travis" <Tr****@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com...
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 ?

--
Travis Tan

Feb 20 '06 #2
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 Tan
"C.C. (aka Me)" wrote:
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.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Travis" <Tr****@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com...
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 ?

--
Travis Tan


Feb 21 '06 #3
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.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Travis" <Tr****@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
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 Tan
"C.C. (aka Me)" wrote:
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.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Travis" <Tr****@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com...
> 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 ?
>
> --
> Travis Tan


Feb 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

88
5055
by: Tim Tyler | last post by:
PHP puts most of its functions into a big flat global namespace. That leads to short function names - but creates a namespace minefield for programmers. Lots of the functions are legacies from...
11
2530
by: Capstar | last post by:
Hi, I am working on an application, which will run embedded without an OS. The app is build up out of a couple of well defined parts. At first I wanted to keep those parts seperated and use...
7
3107
by: Michael | last post by:
Hi newsgroup, as the subject indicates I am looking for an advice using global variables. I am not if this problem is more about style then C. If its wrong in thi group, sorry. So I have a...
10
1940
by: ankisharma | last post by:
Hi all At many places I have seen that programmers pass global variables to functions in c. I am not able to figure out why they do so. need some clues on this. somewhere i heard that this...
10
6743
by: David P. Donahue | last post by:
When I wrote websites in VB .NET, I would often put functions in Global for all the pages to call. Now, in C#, doing so results in "references to non-static objects" and whatnot. I realize what...
14
1644
by: Alan Silver | last post by:
Hello, I have spent ages trawling through Google, looking for information about global functions in ASP.NET and I'm still not clear about the best way to go about this (or not). I am writing...
7
2558
by: zeecanvas | last post by:
Hi, First of all: Yes, I know global variables are bad, but I've a huge amount of legacy code, and I've to maintain it _as_is_. I'm maintaining a big program. I moved all (program-wide scope)...
10
2631
by: Charles O'Flynn | last post by:
As a complete newcomer (2-3 days) to PHP, although not to programming in general, I have 'dived in' to start a small project to read and parse an XML data stream. I have already worked out most of...
9
8620
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
1
29312
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.