【发布时间】:2010-04-25 14:28:02
【问题描述】:
这是我的课:
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)
{
}
}
我的印象是 ref 关键字告诉计算机使用相同的变量而不是创建新变量。
我是否正确使用它?我必须在调用代码行和实际方法实现上都使用 ref 吗?
【问题讨论】: