.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 8th, 2003, 08:22 PM
helenvale helenvale is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 28 helenvale User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
C#: Accessing nonstatic member

Is there any way to access a nonstatic member (either method or variable) of outer class from nested (inner) class? Please help. Thanks.

Reply With Quote
  #2  
Old October 9th, 2003, 01:05 PM
manual63's Avatar
manual63 manual63 is offline
Sk8er Punk!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Minneapolis, MN
Posts: 96 manual63 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
Send a message via Yahoo to manual63
The only way you can do this is if there is a public method in the same class as the non static variables that you can call that changes them. I am not entirely sure, but I think this is the only way to do it. I always get static and non-static mixed up with public and private. Static basically means global, but I am still fuzzy on it.
__________________
if (Bush == "idiot") return "Bush is an Idiot";
else if (Bush != "idiot") return "Bush is still an idiot";

http://www.yourpolitics.org

Reply With Quote
  #3  
Old October 9th, 2003, 11:18 PM
oni9 oni9 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Brisbane, Australia
Posts: 50 oni9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
nonstatic variable is called "class variable" in my old java text book

and I do recall that outter class and inner class relationship is like : outter class inherits inner class

which means you have your constructor defined like this:
public OutterClassObject(): InnerClassObject
{
//construction code
}


to access the inner class class variable, you must have your inner class class variable defined as protect or public. You cannot access private inner class class variable.

Those accessibility rule are inherited from C++



by the way, if you are after something like manual63 says, then here is a further note of the rules:
you cannot access class variable by static method (or global calls) simply because your class was never "constructed" when you do a static call or global call.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > C#: Accessing nonstatic member

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap