Click here to Skip to main content
15,885,767 members
Home / Discussions / C#
   

C#

 
GeneralRe: Determing SQL Server Type from C# Pin
leppie29-Oct-02 10:23
leppie29-Oct-02 10:23 
GeneralRe: Determing SQL Server Type from C# Pin
perlmunger29-Oct-02 10:54
perlmunger29-Oct-02 10:54 
GeneralRe: Determing SQL Server Type from C# Pin
leppie29-Oct-02 11:05
leppie29-Oct-02 11:05 
GeneralRe: Determing SQL Server Type from C# Pin
perlmunger29-Oct-02 11:11
perlmunger29-Oct-02 11:11 
GeneralRe: Determing SQL Server Type from C# Pin
leppie29-Oct-02 11:39
leppie29-Oct-02 11:39 
GeneralRe: Determing SQL Server Type from C# Pin
Stephane Rodriguez.29-Oct-02 18:36
Stephane Rodriguez.29-Oct-02 18:36 
GeneralRe: Determing SQL Server Type from C# Pin
perlmunger30-Oct-02 9:07
perlmunger30-Oct-02 9:07 
GeneralPass By Reference Problem Pin
perlmunger29-Oct-02 6:34
perlmunger29-Oct-02 6:34 
I'm not sure what is going on here, but I hope there's someone who knows why this happens. Basically, I have a base class and an inherited class, something like this:

public abstract class Base {}
public class Inherited : Base {}


I also have a class that populates inherited objects called ObjectBuilder. It is a singleton and it has a method called PopulateObject. Here is the code to do what I want:
Inherited i = new Inherited();

ObjectBuilder ob = ObjectBuilder.GetInstance();

ob.PopulateObject( ref i );

// Do something with i


The problem is that the signature for PopulateObject takes a ref to Base. If I understand the is-a relationship properly, doing so should work and in fact, when I remove the 'ref' keyword from the declaration as well as implementation, it builds fine. It just won't work properly because it is at that point passing a copy (isn't it?). What is going on here? Why will it build without error when I pass a copy, but fails when I pass by reference?

Any help would be greatly appreciated.

-Matt

------------------------------------------

The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
GeneralRe: Pass By Reference Problem Pin
Daniel Turini29-Oct-02 6:40
Daniel Turini29-Oct-02 6:40 
GeneralRe: Pass By Reference Problem Pin
perlmunger29-Oct-02 6:51
perlmunger29-Oct-02 6:51 
GeneralRe: Pass By Reference Problem Pin
leppie29-Oct-02 7:42
leppie29-Oct-02 7:42 
GeneralRe: Pass By Reference Problem Pin
perlmunger29-Oct-02 9:18
perlmunger29-Oct-02 9:18 
GeneralRe: Pass By Reference Problem Pin
LongRange.Shooter29-Oct-02 8:42
LongRange.Shooter29-Oct-02 8:42 
GeneralRe: Pass By Reference Problem Pin
perlmunger29-Oct-02 9:20
perlmunger29-Oct-02 9:20 
GeneralRe: Pass By Reference Problem Pin
Paul Ingles29-Oct-02 14:40
Paul Ingles29-Oct-02 14:40 
GeneralFloat divisoin Pin
Mazdak29-Oct-02 1:08
Mazdak29-Oct-02 1:08 
GeneralRe: Float divisoin Pin
Pete Bassett29-Oct-02 1:20
Pete Bassett29-Oct-02 1:20 
GeneralRe: Float divisoin Pin
Nick Parker29-Oct-02 1:21
protectorNick Parker29-Oct-02 1:21 
GeneralRe: Float divisoin Pin
Mazdak29-Oct-02 4:03
Mazdak29-Oct-02 4:03 
GeneralDrag and Drop Pin
Buddhi28-Oct-02 23:36
Buddhi28-Oct-02 23:36 
QuestionHow to count event subscriptions Pin
BigAndy28-Oct-02 23:11
BigAndy28-Oct-02 23:11 
AnswerRe: How to count event subscriptions Pin
Stephane Rodriguez.29-Oct-02 0:04
Stephane Rodriguez.29-Oct-02 0:04 
GeneralRe: How to count event subscriptions Pin
BigAndy29-Oct-02 1:28
BigAndy29-Oct-02 1:28 
GeneralRe: How to count event subscriptions Pin
Stephane Rodriguez.29-Oct-02 1:56
Stephane Rodriguez.29-Oct-02 1:56 
GeneralC# .NET and Microsoft Excel Pin
mee28-Oct-02 16:22
mee28-Oct-02 16:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.