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

C# - Basic Question

9
Hey guys, I know this is probably a very easy, basic question, so feel free to direct me to a detailed answer. I have done some searches some some of the information I get is vague.

In C#, the basic idea I understand is to store information in objects to be used by other objects later. So to say building blocks of the program. My question is this. If I Make Object A, and then Object B, and in Object B I set a variable (can't think of a way to say it better) to equal Object A does this "copy" or "point" to Object A from Object B?

I ask because I am confused, if I make changes in Object A from the reference in Object B, is the orginal Object A going to inherit those changes as well?

Thanks
Aug 6 '08 #1
3 1371
Plater
7,872 Expert 4TB
So class definitions:
Expand|Select|Wrap|Line Numbers
  1. public class objA
  2. {
  3.    public int SomeVal=0;
  4. }
  5.  
  6. public class objB
  7. {
  8.    public objA myobjA;
  9. }
  10.  
Then
Expand|Select|Wrap|Line Numbers
  1. objB myobjB = new objB();
  2. objA myoA = new objA();
  3.  
  4. myobjB.myobjA=myoA;
  5. //myobjB.myobjA IS now myoA, I believe any changes to myoA would be reflected in myobjB.myobjA, and vice-versa
  6.  
I would think a tutorial on Object Oriented Programming (OOP) would be able to explain it better then I can.
Aug 6 '08 #2
It is like Plater said, if you say

objb.obja = obja

all that objb.obja is getting is a pointer to obja, and any changes to objb.obja will be reflected in obja.

If you do not want just a pointer, you would have to do something like

objb.obja = new obja(obja.values n' such).

You would still have objb.obja AND obja and they would be two different objects.

Hope that's what you were looking for.
Aug 6 '08 #3
Tenowg
9
that is exactly what I was looking for... Thanks very much
Aug 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: pauldepstein | last post by:
I am reading Grimshaw and Ortega's "C++ and Numerical Methods." They construct a vector class which contains the variable vec, a float* variable where the length of the array (number of...
6
by: DH | last post by:
I have a VERY basic question about figuring database size. I've inherited a database which is generally similar to this basic one: Item, Red, Blue, Green, Yellow (text), (int),(int),(int),(int)...
9
by: Malcolm | last post by:
After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter. The question is, how is it most useful? At the moment I have a function int basic(const char *script,...
4
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time...
13
by: Pete | last post by:
I'm cross posting from mscom.webservices.general as I have received no answer there: There has been a number of recent posts requesting how to satisfactorily enable BASIC authorization at the...
5
by: Aussie Rules | last post by:
Hi, Having a mental block on this one. Have done it before but can't rack my brain on how... I have an object, with a bunch on property, and I add that object to a combo box. I want the...
4
by: MikeB | last post by:
I've been all over the net with this question, I hope I've finally found a group where I can ask about Visual Basic 2005. I'm at uni and we're working with Visual Basic 2005. I have some books, ...
1
by: frankhanretty | last post by:
Do I have to install Visual basic on the remote terminals as I did on the server? I have an visual basic 5 application running fine on my client's server and he is now networked. He wants to run the...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
3
by: Scott Stark | last post by:
Hello, I'm trying to get a better handle on OOP programming principles in VB.NET. Forgive me if this question is sort of basic, but here's what I want to do. I have a collection of Employee...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...

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.