473,378 Members | 1,403 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,378 software developers and data experts.

Accessing Owner class instance possible?

Hello,

I have a class inside another class. The Scenario is like Car->Engine, where
Car is a class with a set of properties and methods and Engine is another
class inside it with its own set of properties.

I want to know if there is a way to access the methods and the properties of
the Owner class for the class that's inside it? I.e. I want to find out
within Engine what make the Car is which is exposed by the property
Car.Model.

Is there any way I can do that?

:) Thanks for reading.

Cheers
Cyril Gupta
Jan 4 '06 #1
5 2674
"Cyril Gupta" <no****@mail.com> schrieb:
I have a class inside another class. The Scenario is like Car->Engine,
where Car is a class with a set of properties and methods and Engine is
another class inside it with its own set of properties.

I want to know if there is a way to access the methods and the properties
of the Owner class for the class that's inside it? I.e. I want to find out
within Engine what make the Car is which is exposed by the property
Car.Model.


You will have to pass a reference which points to the 'Car' instance to the
'Engine' class instance.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 4 '06 #2
Cyril,

The class is only a template.

You use the object.

So in my opinion should there be as there is a
Car.Engine as well a Car.Mark

If you have done
dim myEngine as Car.Engine
Than the myEngine is normally if you have not done something extra as done
in a datarow an individual object.

In a datarow there is a special property DataTable, which tells to which
datatable a datarow belongs.

However that is an extra property in the Class of the datarow.

I hope this helps,

Cor
Jan 4 '06 #3
Hi, Cyril,
Ultimately, having a class defined inside another class primarily impacts two things: the way you refer to the nested class (i.e., fully qualified from the outside world, though not to the enclosing class), and the permissions that the nested class ultimately exposes to the outside world (which are throttled by the access of the enclosing class). Beyond that, the internal class simply works like any other class. The outer class still needs to have member variables which reference that class, and the internal class would likewise need member variables to refer back to the enclosing class (if such was needed).

Personally, I always try to avoid using internal classes which need to refer back to enclosing classes -- if such commerce is always going to be required, then it's not clear why there would be a benefit to factoring code in that fashion in the first place. (In general, I try to avoid such back-references between *any* two classes, regardless of nesting, but sometimes that's not always possible and in any event is beside the point.)

There's more information on nested classes at http://msdn.microsoft.com/library/de...components.asp which discusses the circumstances under which nested class usage makes sense.

Hope this helps!
--Matt--*

-----Original Message-----
From: Cyril Gupta
Posted At: Wednesday, January 04, 2006 8:26 AM
Posted To: microsoft.public.dotnet.languages.vb
Conversation: Accessing Owner class instance possible?
Subject: Accessing Owner class instance possible?
Hello,

I have a class inside another class. The Scenario is like Car->Engine, where
Car is a class with a set of properties and methods and Engine is another
class inside it with its own set of properties.

I want to know if there is a way to access the methods and the properties of
the Owner class for the class that's inside it? I.e. I want to find out
within Engine what make the Car is which is exposed by the property
Car.Model.

Is there any way I can do that?

:) Thanks for reading.

Cheers
Cyril Gupta
Jan 4 '06 #4
Hello Matthew,

Thank you for pointing me to that article, it was quite helpful. I am not
pleased with this either, but it has become important in the context of my
software.

Till now I have avoided referring to the owner class, let's hope I can
continue doing that.

Thanks for helping :)

Cyril Gupta
Jan 5 '06 #5
Yep, that should do it

I guess I can do that when I create an instance of the nested class. Thanks
for the tip

:)

Regards
Cyril Gupta
Jan 5 '06 #6

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

Similar topics

1
by: Mike Frayn | last post by:
Hello there. I'm kinda new to Java, did some last year and have forgotten it all, but am experienced enough with C++. I have a problem here that I would imagine is solved very easily. I have...
4
by: | last post by:
Hi I have a list containing several instance address, for example: I'd like to invoke a method on each of these instance but I don't know : 1. if its possible 2. how to proceed
7
by: Sharon | last post by:
I’m writing a class that need to know the type or name of the class which created me. It can be done if the owner will pass his this, but I would like to do it without the owner intervention....
1
by: Jason Bell | last post by:
Every example of properties I've seen have used simple types such as integers and strings. Here's the scenario I'm trying to work out (3D graphics programming): I have a class called...
3
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
3
by: Dave Coate | last post by:
Hello again, I am going to re-post a question. I got some excellent suggestions from Rob and Mattias on this but their ideas did not solve the problem. Here is the original post: ...
7
by: MarkJ | last post by:
him im kinda new to c-sharp... to reference up the class chain, how do i reference the super class (parent) example class mybase { protected int abc=0 } classs myclass:mybase {
12
by: titan nyquist | last post by:
I have a class with data and methods that use it. Everything is contained perfectly THE PROBLEM: A separate thread has to call a method in the current instantiation of this class. There is...
1
by: nsphelt | last post by:
I am wondering if it is possible to access the underlying property of a base class within a derived that has overridden that property. I am using VB.NET and when I use the MyBase keyword to access...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.