Trouble using the ref keyword. Very newbie question!
Posted
by Sergio Tapia
on Stack Overflow
See other posts from Stack Overflow
or by Sergio Tapia
Published on 2010-04-25T14:28:02Z
Indexed on
2010/04/25
14:33 UTC
Read the original article
Hit count: 344
Here's my class:
public class UserInformation
{
public string Username { get; set; }
public string ComputerName { get; set; }
public string Workgroup { get; set; }
public string OperatingSystem { get; set; }
public string Processor { get; set; }
public string RAM { get; set; }
public string IPAddress { get; set; }
public UserInformation GetUserInformation()
{
var CompleteInformation = new UserInformation();
GetPersonalDetails(ref CompleteInformation);
GetMachineDetails(ref CompleteInformation);
return CompleteInformation;
}
private void GetPersonalDetails(ref UserInformation CompleteInformation)
{
}
private void GetMachineDetails(ref UserInformation CompleteInformation)
{
}
}
I'm under the impression that the ref keyword tells the computer to use the same variable and not create a new one.
Am I using it correctly? Do I have to use ref on both the calling code line and the actual method implementation?
© Stack Overflow or respective owner