-4

I have read many articles related to ref and out parameters and they helped me to understand the basic concept of these parameters but none of these make me clear about where we have to use ref and where we have to use out.

It would be really appreciated if someone can give me an example that shows a scenario where we can use ref parameter to achieve a functionality that can not be achieved by using out parameter and vice verse.

i know the difference between ref and out parameters.

Ref: I know that we always need to initialize a variable before passed it as ref in a method.

Out: I know that we always need to set value of a variable as out parameter in the calling function before it returns a value.

Is there any example exists in which i can use ref parameter but not out and vice verse ?

tnw
  • 13,521
  • 15
  • 70
  • 111
Rajbir Singh
  • 1,641
  • 6
  • 23
  • 46
  • See this linkhttp://stackoverflow.com/questions/1516876/when-to-use-ref-vs-out – Dan Hunex Dec 26 '13 at 18:13
  • @RajbirSingh This has nothing to do with you. It's unclear how your question differentiates from the duplicate it was marked as. – tnw Dec 26 '13 at 19:17
  • @tnw please see the answer give by zneak. It is actually the answer of my question. You guys didn't get my question and marked it as duplicate that's not good. It's really disappointing for me. – Rajbir Singh Dec 26 '13 at 19:20
  • @RajbirSingh If you feel your question was closed inappropriately, you can appeal it on Meta or flag it to have a moderator review the close vote. Even if it isn't a duplicate (which it is), your question would still be off-topic. – tnw Dec 26 '13 at 19:37
  • @tnw That's was fine if you said this question is duplicate. But you guys marked it as not useful that doesn't make sense. We all are here to help each other but not to demotivate anyone. – Rajbir Singh Dec 26 '13 at 19:46
  • @RajbirSingh Again, this has **nothing to do with you**. A duplicate question is, nearly by definition, not a useful addition to the site. I'm unsure what your argument is, you say its fine if the question is a duplicate... which it is and exactly what it was closed as. You're taking this *way* too personally. None of this is a personal attack on you. – tnw Dec 26 '13 at 19:48
  • @RajbirSingh It's perfectly clear you just want examples and in particular examples in which only `ref` can be used or where only `out` can be used. It's still off-topic and still a duplicate. It's abundantly clear you're personally hurt by your question being closed ("i didn't like it", It's really disappointing for me"). If you plan on asking more questions like this, you should try to be less sensitive (it IS the internet...) and stick to more objective, answerable questions. – tnw Dec 26 '13 at 19:59

0 Answers0