windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Select a property parameter (Function) from a Generic Item

Asked By: Anonymous

I have a component in which takes in a generic type and a Func<TItem, string> to select a property as well as a List of said type called Data. To select the property from the list it’s fairly simple: Data.Select(Property) and I get a list of said property. However, what I want to do now is not select the list, but select a single item, TSelected, from the data (if there are any), where the property is equal to some value I called tvalue.

public List<TItem> Data { get; set; }

public Func<TItem, string> Property { get; set; }

public TItem Selected { get; set; }


private string _value;

public string Value
    get => _value;
        // if it is equals do nothing
        if (string.Equals(_value, value) || value == null)

        _value = value;

        var selected = Data.Select(Property).FirstOrDefault(x => string.Equals(value, x));

        if (!string.IsNullOrEmpty(selected))
            /* Don't know how to select the property from a single TItem */
            Selected = Data.Where( x => x.??? == selected).FirstOrDefault();


Answered By: Anonymous

Your Property func accepts a TItem and returns the property that you want, right? So just use it in the where clause.

Selected = Data.Where( x => Property(x) == selected).FirstOrDefault();

techinplanet staff

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno