passing object reference to the method

P

puzzlecracker

Say I pass an object of a class (reference value I suppose) to a
method, and I want to pass it by reference. Do I need to preappend
it with ref.

public interface IFoo{}

public class Foo:IFoo{

}

void FromHere()
{

Foo f=new Foo();
Here(ref f);

}

void Here(ref IFoo f )
{
//do something with f
}

Is ref redundant or error-prone. In my scenerio I have a lot of
overload for Here-like function,
and compiler screams that it cannot convert IFoo to char (latter
beeing void Here(ref char c) )


Thanks
 
P

puzzlecracker

Are your sure this is C++? Most likely CLI/C++ or some
other Microsoft managed version.

Guys, It's csharp. I accidentally post this question here. It's now
reposted to the appropriate group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top