Is there any option to do something like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Student
{
public string PassPort { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Message { get; set; }
public List<string> AllProperties { get; set; }
public Student()
{
AllProperties = new List<string>();
AllProperties.Add(ref PassPort);
AllProperties.Add(ref FirstName);
AllProperties.Add(ref LastName);
AllProperties.Add(ref Message);
}
}
so when I change the AllProperties[0]
it will change the PassPort
string variable???
I am not really sure what it is you are after, but you might be able to use an indexer:
class Student
{
public string PassPort { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Message { get; set; }
public string this[int index]
{
get { throw new NotImplementedException(); }
set
{
switch (index)
{
case 0:
PassPort = value;
break;
case 1:
// etc.
default:
throw new NotImplementedException();
}
}
}
}
And the use that like this:
class Program
{
static void Main(string[] args)
{
Student student = new Student();
student[0] = "PASS";
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다