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

Home Posts Topics Members FAQ

How does a nested class reference it's containing class.

I need some quick advice.
I just need to reference a containing class from the nested class. I'm
familiar with Java but C# is proving tricky.

public BigClass {

public int ID_BigClass = -99;

public MiniClass{
public void MiniFunc(){
//How do i get ID_BigClass?
int intBigClassID = {Reference to instance og Big Class}
}
}

}

Thanks
--
I AM MORTOS!!!! (Switch spammer with blueyonder)

Nov 15 '05
12 4046
Julie wrote:

base is what you want:

int intBigClassID = base.ID_BigClas s;

Mortos wrote:

I need some quick advice.
I just need to reference a containing class from the nested class. I'm
familiar with Java but C# is proving tricky.

public BigClass {

public int ID_BigClass = -99;

public MiniClass{
public void MiniFunc(){
//How do i get ID_BigClass?
int intBigClassID = {Reference to instance og Big Class}
}
}

}

Thanks
--
I AM MORTOS!!!! (Switch spammer with blueyonder)


Forget that -- I'm a partial idiot today and didn't pay attention to the OP's
question.
Nov 15 '05 #11
Actually it should look like this...

public class BigClass
{
private MiniClass _mini = null;

public BigClass()
{
_mini = new MiniClass(this) ;
}

public class MiniClass
{
private BigClass _owner = null;

public MiniClass(BigCl ass owner)
{
_owner = owner;
}
}
}

--
Leit Rachsor
Nov 15 '05 #12
Thanks people for all your responses. These assumptions occasionally
happen for us Java devotees ;-)

I shall amend code as required.

Mortos wrote:
{Snip}

--
I AM MORTOS!!!! (Switch spammer with blueyonder)
Nov 15 '05 #13

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

Similar topics

6
2571
by: Andy Baker | last post by:
Hi there, I'm learning Python at the moment and trying to grok the thinking behind it's scoping and nesting rules. I was googling for nested functions and found this Guido quote: (http://www.python.org/search/hypermail/python-1993/0343.html) "This is because nested function definitions don't have access to the local variables of the surrounding block -- only to the globals of the
4
365
by: Sundararajan | last post by:
Dear Folk, I have implemented a nested class as follows: Class Enclosing { string strName; Class Nested1 { }
9
3690
by: Joel Moore | last post by:
I'm a little confused here. If I have the following: Public ClassA Friend varA As Integer Private varB As Integer Private ClassB Public Sub MethodA() ' How can I access varA and varB here? End Sub
1
2580
by: Craig Buchanan | last post by:
is there an implicitly-defined Parent property defined for a class that is nested in another class? i'm looking to simplify my coding. At this point, i've defined the class as so: Class Item Private _SubItem As New SubItem(Me) 'other properties and methods
1
1650
by: Diane Yocom | last post by:
I have two nested master pages, each with public properties. From my content page, I am able to access properties from both pages using either Master.PropertyName (for the child master page) or Master.Master.PropertyName (for the parent master page). The solution compiles and the HTML looks right, but my code has blue "error" underlines wherever I type Master.Master.PropertyName. When I hover over the underlined code, I get the...
2
2375
by: miked | last post by:
I am architecting in a read only class for use in mapping data to a business object. The object makes strong use of nested classes and their ability to access protected fields. The downside is when a nested class inherits from it’s parent class you get this infinite class chain in intellisense when consuming the class. To get around this I created two child classes Reader and Writer which require a base Person object. When consuming...
1
11818
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an XmlNodeList. I am trying to deserialize the nodes using a foreach as follows: foreach(XmlNode lineItem in LineItemsNodeList) An abbreviated example of the nested lineItem node looks like this:
1
5331
by: =?Utf-8?B?QmFybmV5TGlnaHQ=?= | last post by:
Hi, I have a WCF service contract which has message containing a List<MyType> data member where MyType consists of a string Key and object Value. As expected this gets exposed as a MyType array in the service reference. In the client, I dynamically add Key/Value entries in the list. This works fine as long as I use simple types in the client, but I need to
3
3899
by: puzzlecracker | last post by:
Would you quickly remind me the difference between, regular class, static class, and nested class? Thanks
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
10571
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...
1
10317
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
10075
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
7615
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
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
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.