嘿計算器用戶,訪問的對象在另一個類的屬性功能
得到一個快速
我試圖訪問另一個類的功能的對象的屬性,不是我似乎能讓它工作。
class Program
{
static void Main(string[] args)
{
User PIE = new User();
Userchanger changer = new Userchanger();
changer.ChangeToFailedUser(PIE); //this won't work - The best overloaded method match for 'ConsoleApplication1.Userchanger.ChangeToFailedUser(ref object)' has some invalid arguments
}
}
public class User
{
public string Username = "Firstname.Lastname";
}
public class Userchanger
{
public void ChangeToFailedUser (ref object PIE)
{
object PIEThingy = PIE;
PIEThingy.Username = "AnotherFN.AnotherLN"; //So how do I actually access the object User's Username string variable? It's more important that I can GET the variable rather than edit it.
}
}