R
rellik
Hi All,
Is there a C# version of the C++ pointer (or reference) to member operator -
..* or ->*
Basically I'd like to write a function that can take an object and an offset
to a member of the object to access. For example in the search function
below I'd like to pass in an offset to the member I'd would like to compare
against (in this case _ForeName), meaning I wouldn't have to write a new
function for each member.
struct Person
{
public string _ForeName;
public string _MiddleName ;
public string _Surname ;
}
bool Search(List<Person> arr, string strSearch)
{
foreach(Person person in arr)
{
if(person._ForeName==strSearch) return true ;
}
return false ;
}
Thanks,
-Liam
Is there a C# version of the C++ pointer (or reference) to member operator -
..* or ->*
Basically I'd like to write a function that can take an object and an offset
to a member of the object to access. For example in the search function
below I'd like to pass in an offset to the member I'd would like to compare
against (in this case _ForeName), meaning I wouldn't have to write a new
function for each member.
struct Person
{
public string _ForeName;
public string _MiddleName ;
public string _Surname ;
}
bool Search(List<Person> arr, string strSearch)
{
foreach(Person person in arr)
{
if(person._ForeName==strSearch) return true ;
}
return false ;
}
Thanks,
-Liam