In c# , when sending a parameter to a method, when should we use "ref" and when "out" and when without any of them?
['https://Stackoverflow.com/questions/1115762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61156/']
(this is supplemental to the existing answers - a few extra considerations)

There is another scenario for using `ref` with C#, more commonly seen in things like XNA... Normally, when you pass a value-type (`struct`) around, it gets cloned. This uses stack-space and a few CPU cycles, and has the side-effect that any modifications to the `struct` in the invoked method are lost.

(aside: normally `struct`s should be immutable, but mutable structs isn't uncommon in XNA)

To get around this, it is quite common to see `ref` in such programs.

But in **most** programs (i.e. where you are using `class`es as the default), you can *normally* just pass the reference "by value" (i.e. no `ref`/`out`).

---

Another **very** common use-case of `out` is the `Try*` pattern, for example:

```
string s = Console.ReadLine();
int i;
if(int.TryParse(s, out i)) {
    Console.WriteLine("You entered a valid int: " + i);
}

```

Or similarly, [`TryGetValue`](http://msdn.microsoft.com/en-us/library/zkw5c9ak(VS.85).aspx) on a dictionary.

This could use a tuple instead, but it is such a common pattern that it is reasonably understood, even by people who struggle with too much `ref`/`out`.
Very simple really. You use exactly the same keyword that the parameter was originally declared with in the method. If it was declared as `out`, you have to use `out`. If it was declared as `ref`, you have to use `ref`.