相关疑难解决方法(0)

Get Property from a generic Object in C#

have a look at this code please:

public void BindElements<T>(IEnumerable<T> dataObjects)
{
    Paragraph para = new Paragraph();

    foreach (T item in dataObjects)
    {
        InlineUIContainer uiContainer =
            this.CreateElementContainer(item.FirstName ????? )              
        para.Inlines.Add(uiContainer);
    }                         

    FlowDocument flowDoc = new FlowDocument(para);
    this.Document = flowDoc;
}
Run Code Online (Sandbox Code Playgroud)

When in write in Visual Studio "item.XXX" I should get the properties from my entitiy like .FirstName or .LastName. I do not know wether dataObjects is an IEnumerable or IOrder etc... it must be generic!

How can I get the …

c# generics get properties object

3
推荐指数
1
解决办法
5063
查看次数

标签 统计

c# ×1

generics ×1

get ×1

object ×1

properties ×1