473,804 Members | 3,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NonStatic erorr

I am a little new to C# and an have a hard time understanding why I get a
nonstatic error. I create an object in my main form that has member
properties by using a control. From another form/dialog I try to access that
object to set a property. I get a non static error. I can change my object
to static, which works fine. Static objects are acting as I expect. Non
static objects are not. I do not understand why this is happening. I have
made it public and am in the same name space for my project. It seem that I
can only use an object in the same class that I created it in. In this case
I created my object in my main form class and can access easly from any
control in that class and set any property, however if I try to access this
object from another form/dialog class I recieve a non static error.

Thx,
Jan 6 '07
10 1316
Muffin <mu****@NoEmail .localwrote:
If a member is public, that means
you've got access to it from any assembly. However, if it's an instance
member, you still need to know *which* object you're talking about

public config myConfig = new config();
I'm not sure what that's meant to tell us, but unless you then specify
that you want to use myConfig in order to get to things, it's not going
to make any odds.
I have quite a few books on introductory C# of which I have read at laest
once. I still get stuck though.
I'd reread them, concentrating specifically on understanding how
objects are referenced. Note that this is *not* an access issue in
terms of public/private.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 7 '07 #11

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

Similar topics

3
4732
by: Hiusing Ngai | last post by:
Hello, I'm porting some C code to VC++ 7. A line of C code is: int (*v); and the C code allocate memory: v = calloc (width*5, sizeof **v); The VC++ 7 has the following erorr when I compile the program. error C2440: '=' : cannot convert from 'void *' to 'int (*)'
8
2972
by: Jinesh | last post by:
I illustrate the compiler error I get using the following example. --------------------------------------------------------------- Class ClassName { private: static const int constVarName = 100; void functionName(int parameterName) }; void ClassName::functionName(int parameterName=constVarName)
7
2524
by: Chris Clement | last post by:
I have been handed a project that someone else started and most of it was developed in the VS.NET design mode. For whatever reasons, when I try to make changes to the controls in VS.NET design mode, I suddenly get a ton of these errors: cs(1189): 'class.form.checkedListBox1' denotes a 'field' where a 'class' was expected I was not getting any errors until I made a couple of changes within VS.NET. So I'm trying to understand why...
7
15020
by: The|Godfather | last post by:
Hi everybody, I read Scotte Meyer's "Effective C++" book twice and I know that he mentioned something specific about constructors and destructors that was related to the following error/warning: "error: invalid use of nonstatic data member " However, he did NOT mention this error in the book explicitly.It happens always in the constructor when you try to initialize some data members in the constructor and try to accsess other data...
2
2248
by: chitra lekhaa | last post by:
#include<stdio.h> #include<conio.h> these two are important for my program but this only are giving erorr for me the file is not opening
3
1402
by: fard | last post by:
Hi Everyone i have a table with tow column "Err Number" And "Custom Message" now! Please help me that how can i use the onErorr event to change the default message with my "Custom Message" by using this table. i now that i can use this metode for one message. if DataErr = 0000 then msgbox "xxxxxxxxxx" Response=acDataErrContinue end if
1
1169
by: preeti13 | last post by:
i am trying to dispaly a datagrid but getting the erorr please any one help me with this. private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here SqlConnection oConn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings); SqlDataAdapter da=new SqlDataAdapter("up_reason", oConn); DataSet ds=new DataSet();
1
1433
by: RAJAKUMARMCA | last post by:
what are the erorr in c how to use 1bit for int data type, so what is its range?
6
2217
by: fl | last post by:
Hi, There is a question about nonstatic member. C++ primer says: A nonstatic member is restricted to being declared as a pointer or reference to an object of its class. It only gives an example of pointer *b. class Bar { public: private:
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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
10332
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
10320
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
10077
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...
1
7620
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
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
3
2991
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.