Is there a quick way to know if the return value is a copy or reference?

In C++ the intellisense displays if the return value is a pointer which is really nice.

Is there a way to know easily if the assignment will yield a copy or a reference



Answer this question

Is there a quick way to know if the return value is a copy or reference?

  • xpmedia

    Any particular reason why this is not provided for C# I just think it really nice if you don't have to look at the help file everytime you first use a new method(also the assign operator for first-time use object) or to learn about a method you used 2-3 months ago.

    This just came to my mind after I was asked to fix a bug in an area of a software that I'm not normally assigned to because the main guy is on vacation. I'm not into second guessing what other programmers do, so mostly, I concertrate on "logic" part of the code that someone else wrote instead of scrutinizing his/her coding style. 


  • Davy Van Melkebeke

    No, there isn't. Normally it is specified in the documentation of the method.

    If you want to specify this with your own method you can use the Xml Domentation Comment of C#, see: XML Documentation Comments (C# Programming Guide).


  • hklbj

    In C# you can't return a pointer, only a IntPtr for example. So normally when you see the return type you know enough.

    If thinks are a copy or not can't be marked by a type. This is allways the documentation that can tell you such things.

    Can you give us an example when you need it with relevant code


  • Is there a quick way to know if the return value is a copy or reference?