Friday, December 02, 2011

Parameters: Call “by value” and “by reference” 2

Reference type objects are already having reference in it. So mostly there will be no need to pass them by reference.

public void ChangeText(TextBox txt)
{
    txt.Text = DateTime.Now.ToString();
}

Whatever TextBox we pass it to this method, Text of that TextBox will be changed. There is no need to mark it with “ref” keyword.

No comments:

Post a Comment