I have a class called "Account". Here are my codes:
// Account.cs
public partial class Account
{
private Account.Credential _credential = new Account.Credential();
public void Login(string UserID, string UserPW)
{
try
{
// do something
_credential.CookieCollection = browser.CookieCollection;
_credential.CookieContainer = browser.CookieContainer;
_credential.UserID = "test";
_credential.UserPW = "test";
}
catch (Exception err)
{
throw err;
}
}
}
// Credential.cs
public partial class Account
{
public class Credential
{
// Model
public CookieCollection CookieCollection { get; set; }
public CookieContainer CookieContainer { get; set; }
public string UserID { get; set; }
public string UserPW { get; set; }
}
}
// Form1.cs
public void ABC()
{
Account[] _account = new Account[2];
_account[0].Login("myID", "myPW");
Account.Credential _cred = _account[0].Credential; ---> I get an error.
}
But when I write a mothod call the Account class in array and call the sub class which is Credential, it gives me an error.
'Credential': cannot reference a type through an expression; try 'Account.Credential' instead.
Because, Login method is in Account Class I should have make an array of Account class. Not Credential class.
Does anyone know how to fix this?