mardi 21 avril 2015

Would reflection be the best method of searching for a value of a specific property in a list of Objects?

I have a Class with the following:

public class TestClass {
    string Account1 {get;set;}
    string Account2 {get;set;}
    string Account3 {get;set;}
}

What I would like is to be able to have a method that is similar to the following:

public TestClass[] GetTestClass(string value, string AccountName)

where i can pass in a value say "John" and the AccountName would be "Account1"

and it will go through a list of TestClass and return an array or list of TestClass objects where there exists a value "John" in the Property "Account1"

Is there a better method of doing this or any thoughts would help.

Note: This is a model based of a SQL Table





Aucun commentaire:

Enregistrer un commentaire