Click here to Skip to main content
15,896,111 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Wordpress site showing thousands of modified files every day - normal process for database website or not? Pin
Slacker0079-Jun-16 23:34
professionalSlacker0079-Jun-16 23:34 
GeneralRe: Wordpress site showing thousands of modified files every day - normal process for database website or not? Pin
Charles Programmer11-Jun-16 6:39
Charles Programmer11-Jun-16 6:39 
GeneralHow is the express module both a function/method AND an object with properties? Pin
Bertrand729-Jun-16 7:22
Bertrand729-Jun-16 7:22 
GeneralRe: How is the express module both a function/method AND an object with properties? Pin
DaveAuld9-Jun-16 7:35
professionalDaveAuld9-Jun-16 7:35 
GeneralRe: How is the express module both a function/method AND an object with properties? Pin
Mark_Wallace9-Jun-16 9:46
Mark_Wallace9-Jun-16 9:46 
GeneralHey Marc Clifton! Pin
#realJSOP9-Jun-16 6:53
professional#realJSOP9-Jun-16 6:53 
GeneralRe: Hey Marc Clifton! Pin
Kevin Marois9-Jun-16 7:31
professionalKevin Marois9-Jun-16 7:31 
GeneralRe: Hey Marc Clifton! Pin
Kevin Marois9-Jun-16 7:37
professionalKevin Marois9-Jun-16 7:37 
So I just did this:
class Program
{<br />
    static List<Person> people = new List<Person>();
    static void Main(string[] args)
    {
        people.Add(new Person { Name = "Joan", Age = 102 });
        people.Add(new Person { Name = "Pete", Age = 50 });
        people.Add(new Person { Name = "Walter", Age = 65 });
        people.Add(new Person { Name = "Joan", Age = 17 });
        people.Add(new Person { Name = "Walter", Age = 25 });

        var person1 = people.FindExact<Person>("Name", "Pete");
        var person2 = people.FindFirstExact<Person>("Name", "Walter");
        var person3 = people.FindLastExact<Person>("Name", "Joan");
    }
}
public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }

    public override string ToString()
    {
        return Name + " - " + Age.ToString();
    }
}

Works great - if what you're looking for is a string. Maybe enhance so I could search on any property type?

Something similar to this:
public static List<T> FindExact<T,P>(this List<T> list, string valuePropertyName, P propertyValue)
{
    List<T> found = default(List<T>);
    try
    {
        PropertyInfo info = typeof(T).GetProperty(valuePropertyName);
        found = (from item in list
                    let value = (string)(info.GetValue(item, null))
                    where (P)value == propertyValue
                    select item).ToList();
    }
    catch (Exception)
    {
    }
    return found;
}

(won't compile, but the idea is nice
If it's not broken, fix it until it is


modified 9-Jun-16 13:43pm.

GeneralRe: Hey Marc Clifton! Pin
#realJSOP9-Jun-16 8:36
professional#realJSOP9-Jun-16 8:36 
GeneralRe: Hey Marc Clifton! Pin
Vincent Blais9-Jun-16 8:02
professionalVincent Blais9-Jun-16 8:02 
GeneralRe: Hey Marc Clifton! Pin
Richard Deeming9-Jun-16 8:32
mveRichard Deeming9-Jun-16 8:32 
GeneralRe: Hey Marc Clifton! Pin
#realJSOP9-Jun-16 8:38
professional#realJSOP9-Jun-16 8:38 
GeneralRe: Hey Marc Clifton! Pin
Richard Deeming9-Jun-16 9:33
mveRichard Deeming9-Jun-16 9:33 
GeneralRe: Hey Marc Clifton! Pin
Dan Neely10-Jun-16 3:25
Dan Neely10-Jun-16 3:25 
GeneralRe: Hey Marc Clifton! Pin
Richard Deeming10-Jun-16 6:10
mveRichard Deeming10-Jun-16 6:10 
GeneralRe: Hey Marc Clifton! Pin
Vincent Blais9-Jun-16 8:42
professionalVincent Blais9-Jun-16 8:42 
GeneralRe: Hey Marc Clifton! Pin
#realJSOP10-Jun-16 2:05
professional#realJSOP10-Jun-16 2:05 
GeneralRe: Hey Marc Clifton! Pin
Richard Deeming10-Jun-16 6:07
mveRichard Deeming10-Jun-16 6:07 
GeneralRe: Hey Marc Clifton! Pin
Mark_Wallace9-Jun-16 13:50
Mark_Wallace9-Jun-16 13:50 
GeneralRe: Hey Marc Clifton! Pin
BillWoodruff9-Jun-16 15:35
professionalBillWoodruff9-Jun-16 15:35 
GeneralRe: Hey Marc Clifton! Pin
Middle Manager10-Jun-16 3:00
Middle Manager10-Jun-16 3:00 
GeneralMicrosoft's BITS file transfer tool fooled into malware distribution Pin
237419-Jun-16 6:33
237419-Jun-16 6:33 
GeneralRe: Microsoft's BITS file transfer tool fooled into malware distribution Pin
Pete O'Hanlon9-Jun-16 6:51
mvePete O'Hanlon9-Jun-16 6:51 
GeneralRe: Microsoft's BITS file transfer tool fooled into malware distribution Pin
237419-Jun-16 6:55
237419-Jun-16 6:55 
GeneralRe: Microsoft's BITS file transfer tool fooled into malware distribution Pin
Joe Woodbury9-Jun-16 8:28
professionalJoe Woodbury9-Jun-16 8:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.