473,666 Members | 2,480 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 1517
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****@discuss ions.microsoft. com> wrote in message
news:58******** *************** ***********@mic rosoft.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****@discuss ions.microsoft. com> wrote in message
news:58******** *************** ***********@mic rosoft.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****@discuss ions.microsoft. com> wrote in message
news:93******** *************** ***********@mic rosoft.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****@discuss ions.microsoft. com> wrote in message
news:58******** *************** ***********@mic rosoft.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
5118
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 the days before PHP got object-oriented features. For instance we currently have:
11
2549
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 opaque data types to transfer information in between them. At some stage I was stuck and needed to make a variable global, and I also needed to make the struct declaration public to some other parts. Looking through the code I found out that lots...
7
3130
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 couple of function that all need the same information (all located in the same file). By now it looks like /* file beginns */
10
1960
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 philosophy is from object orieted world but is it applicable for c?
10
6760
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 that means and all, but what I'm wondering is what's the best way around it? Say, for example, I want a function that takes a username and a password and returns true or false if it's a successful login, and I want any page or usercontrol in the...
14
1654
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 a site that will be for members only. They will have to log in to gain access to any of the pages. I am holding the user information in an XML file (there will probably never be a large number of user, so this is efficient enough).
7
2571
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) global variables outside of the files they were defined it, and created some files that just hold global variables definitions (just variables, without any function definition). So, depending on the purpose/category of variables, they're defined...
10
2646
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 the more specialist aspects of the job but am now completely stuck on something I would have thought were simplicity itself... I need to have a large number of global variables visible inside functions - it's not possible to pass them into the...
9
8644
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 Su Gatlin, casual mention was made about using static variables as an alternative to using global variables. This caused me to think of the following: '-----Begin module code
1
29345
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 called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
0
8362
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8878
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8785
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8560
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8644
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4200
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.