473,379 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How to make Global functions for many classes in C#

I have created control array classes for buttons and textboxes and affixed
them to a form class. In VB I can easily create a module with fuctions that
can be accessed from any class. How can I do the same in C#? When I use the
'Static' keyword I get an error.

For example when I try to change the BackColor of an instance of a TextBox
object on the form from a ButtonArray class event handler function also on
the form I get this error: "An object reference is required" . I think it
wants me to create another instance of the TextBox array which means I will
be working with different objects.

I'm looking to create a bucnch of fuctions that can pass values and change
other object properties.

I can't figure this one out. Its probably very simple but I've just been
made stupid from using vb for so long.

Poe
Nov 17 '05 #1
1 1114
Fri. Aug. 20, 2004 11:10 AM PT

Try creating a global, class, and add all your globals (functions, fields,
variables, properties) as static in this class, or create a SingleTon class,
and also, this will allow you to use Static, and instance members of the
class, Instantiate this object, in your main function.

Good Luck.!!!

"Poewood" <Po*****@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com...
I have created control array classes for buttons and textboxes and affixed
them to a form class. In VB I can easily create a module with fuctions that can be accessed from any class. How can I do the same in C#? When I use the 'Static' keyword I get an error.

For example when I try to change the BackColor of an instance of a TextBox
object on the form from a ButtonArray class event handler function also on
the form I get this error: "An object reference is required" . I think it
wants me to create another instance of the TextBox array which means I will be working with different objects.

I'm looking to create a bucnch of fuctions that can pass values and change
other object properties.

I can't figure this one out. Its probably very simple but I've just been
made stupid from using vb for so long.

Poe

Nov 17 '05 #2

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

Similar topics

88
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...
0
by: Chris F Clark | last post by:
In our C++ project we have some internal bug reporting macros that we use to get useful information when the program does something unexpected. Essentially at the point of the error, we invoke an...
2
by: Patrick | last post by:
Hi I have a problem in my C++ Funktion. I needed an 2 dimensional Array. For this i took a template script in order to create the array in the funktion. The Size of the Array I have to calculate...
8
by: Jan-Henrik Grobe | last post by:
Hallo, normally I am not the one who calls a Newsgroup if something does not work. But now I am frustrated. I did write a program with a lot classes. I use some gloabl variables which are in a...
2
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. Below I have the text from the book and the code from the file where main is located and some...
59
by: seberino | last post by:
I've heard 2 people complain that word 'global' is confusing. Perhaps 'modulescope' or 'module' would be better? Am I the first peope to have thought of this and suggested it? Is this a...
4
by: Simon Harris | last post by:
Hi All, I'm new to ASP.Net, so be gentle! (Plenty of 'classic' ASP experience), just one question... - Am I correct in thinking that global functions are stored in ASCX files? Thanks! ...
2
by: Bryan | last post by:
Hello, I'm just starting to develop in asp.net and i have a question about using a database connection globally in my app. I have set up the procedures for getting all my connection string info...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.