Jin Framework Solutions
Jin Framework Solutions
Jin Framework Solutions
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Jin Framework Solutions

Discussion forum for employee's
 
HomeHome  PortalPortal  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  
Similar topics
    Search
     
     

    Display results as :
     
    Rechercher Advanced Search
    Latest topics
    » unit testing framework
    How to find objects in Generics with List.Find() method EmptyMon Dec 12, 2011 6:59 pm by Admin

    » linq pad -=--------------
    How to find objects in Generics with List.Find() method EmptyMon Dec 12, 2011 6:56 pm by Admin

    » deployment
    How to find objects in Generics with List.Find() method EmptyTue Oct 04, 2011 7:47 pm by rhian23

    » HTTP Error 500.23
    How to find objects in Generics with List.Find() method EmptySat Oct 01, 2011 12:01 pm by Admin

    » code documentation on vs2010
    How to find objects in Generics with List.Find() method EmptyWed Sep 21, 2011 1:15 pm by Admin

    » How to find objects in Generics with List.Find() method
    How to find objects in Generics with List.Find() method EmptyFri Sep 16, 2011 12:45 pm by Admin

    » form movement formborderstyle=none
    How to find objects in Generics with List.Find() method EmptyThu Sep 15, 2011 4:26 pm by Admin

    » code snippet rowdatabound binding a control
    How to find objects in Generics with List.Find() method EmptyMon Sep 05, 2011 8:43 am by Admin

    » Bug Tracking Tool
    How to find objects in Generics with List.Find() method EmptyTue Aug 23, 2011 3:23 pm by Admin

    Navigation
     Portal
     Index
     Memberlist
     Profile
     FAQ
     Search
    Forum
    Affiliates
    free forum


     

     How to find objects in Generics with List.Find() method

    Go down 
    AuthorMessage
    Admin
    Admin
    Admin


    Posts : 404
    Join date : 15/06/2011
    Age : 42
    Location : Caloocan Philippines

    How to find objects in Generics with List.Find() method Empty
    PostSubject: How to find objects in Generics with List.Find() method   How to find objects in Generics with List.Find() method EmptyFri Sep 16, 2011 12:43 pm

    I've been looking for help on how to find objects in Generics with List.Find() method .... and ... take a look what I have found.
    In the follow example, I created a simple class:

    public class Person
    {
    private int _id;
    private string _name;

    public int ID { get{ return _id;} set{ _id = value;}}
    public int Name { get{ return _name;} set{ _name= value;}}

    public Person(int id, string name)
    {
    _id = id;
    _name = name;
    }
    }

    In the example, there's a simple class with two private attributes. Now we're going to create a typed List of this object and take advantage of the Find() method

    public void CreateAndSearchList()
    {
    //create and fill the collection
    List<Person> myList = new List<Person>();
    myList.Add(new Person(1, "AndreySanches"));
    myList.Add(new Person(2, "AlexandreTarifa"));
    myList.Add(new Person(3, "EmersonFacunte"));

    //find a specific object
    Person myLocatedObject = myList.Find(delegate(Person p) {return p.ID == 1; });
    }

    This is the fastest way to find objects using Generics.

    Enjoy it !!!!
    Back to top Go down
    https://jinframeworksolution.forumtl.com
    Admin
    Admin
    Admin


    Posts : 404
    Join date : 15/06/2011
    Age : 42
    Location : Caloocan Philippines

    How to find objects in Generics with List.Find() method Empty
    PostSubject: Re: How to find objects in Generics with List.Find() method   How to find objects in Generics with List.Find() method EmptyFri Sep 16, 2011 12:45 pm

    Back to top Go down
    https://jinframeworksolution.forumtl.com
     
    How to find objects in Generics with List.Find() method
    Back to top 
    Page 1 of 1
     Similar topics
    -
    » format of list of questions and URD

    Permissions in this forum:You cannot reply to topics in this forum
    Jin Framework Solutions :: Software Development Related :: C#-
    Jump to: