mercredi 10 janvier 2018

Reflection - Get all properties values which marked certain attribute [duplicate]

This question already has an answer here:

I have a class RspServer that contains few properties (Getters/Setter). With every property, I have an attribute associated with it. Server is returning a NameValueCollection object, that contains key & value for RspServer class. How can I get values for this class RspServer from NameValueCollection object using Reflection. Please advise

public class RspServer
{
    private string _receiptNum,_respCode;

    [Description("Receipt Number")]
    public string ReceiptNum
    {
        get { return _receiptNum; }
        set { _receiptNum = value; }
    }

    [Description("Response Code")]
    public string RespCode
    {
        get { return _respCode; }
        set { _respCode = value; }
    }
}





Aucun commentaire:

Enregistrer un commentaire