passing object reference to the method
- From: puzzlecracker <ironsel2000@xxxxxxxxx>
- Date: Tue, 30 Sep 2008 08:52:50 -0700 (PDT)
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
.
- Follow-Ups:
- Re: passing object reference to the method
- From: Jon Skeet [C# MVP]
- Re: passing object reference to the method
- From: Anthony Jones
- Re: passing object reference to the method
- Prev by Date: Re: Deserialization issue
- Next by Date: Re: IComparer, Compare, CompareTo for multiple comparisons for Sor
- Previous by thread: File Access via the Web
- Next by thread: Re: passing object reference to the method
- Index(es):
Relevant Pages
|