pass parameters with reference:
ref and out same:
both the method definition and the calling method must explicitly use the ref keyword.
both the method definition and the calling method must explicitly use the out keyword
static void Method(out int i, out string s1, out string s2)
{
i = 44;
s1 = "I've been returned";
s2 = null;
}
static void Main()
{
int value;
string str1, str2;
Method(out value, out str1, out str2);
// value is now 44
// str1 is now "I've been returned"
// str2 is (still) null;
}
Different:
An argument passed to a ref parameter must first be initialized. This differs from out, whose argument need not be explicitly initialized before being passed.