1

I'm using custom attribute to convert value to property, I can't define attribute to property since I'm getting property from some other dll. Is there any way to apply my custom converter attribute to property in my code.

    [Converter(typeof(MyConverter))]
    public double Amount
    {
        get
        {
            return amount;
        }
        set
        {
            amount = value;
        }
    }

I can do this but since the property is not defined within my code, I want to do it in somewhere else.

Amount.Attribute.Converter(MyConverter); I want something like this

  • You can add the attribute at runtime, check: https://stackoverflow.com/a/24413055/9748260 – Sohaib Jundi Aug 01 '19 at 06:16
  • @SohaibJundi, from the suggested link I can't get the solution I think they dit it for method and that also not working for me. I just want to apply attribute to property. Could you please help me to solve this? – Karthik Raja AKR Aug 01 '19 at 07:00
  • Check https://learn.microsoft.com/en-us/dotnet/standard/attributes/writing-custom-attributes#declaring-properties. – Lucas Zhang Aug 20 '19 at 07:07

0 Answers0