0

First off, I would like to say sorry for the phrasing of the question, had no idea how to word it.

The issue that I'm running into is that I need to reference a public decimal by name from a string value.

public decimal **DecimalValue**
    {
        get => GetProperty<decimal>();
        set => SetProperty(value, SomeFunc);
    }

The decimal is structured as above. I would then like to reference it in this function:

AddFiveToValue = Resolve<AsyncExecutingParameterCommand<AddingParametersModel>>().WithExecute(parameters =>
        {
            //In a perfect world, I could approach it as such:
            nameof(parameters.Parameter) += parameters.Increment
            //The string "parameters.Parameter" contains the string of the name of "**DecimalValue**" 
            //that I would like to influence
            return Task.CompletedTask;
        });

All of these can be found within the same class.

Thank you for taking the time to look at my code!

Jason
  • 86,222
  • 15
  • 131
  • 146
  • 1
    https://stackoverflow.com/questions/1196991/get-property-value-from-string-using-reflection – Kieran Devlin Nov 26 '21 at 13:26
  • Thank you so much! I have taken a look at this post and maybe Im interpreting it wrong, but I dont seem to have a src to get a property from? – Sebastian van der Westhuizen Nov 26 '21 at 13:29
  • Juste to be sure I understand well what you're asking, you have a property name as a string in an instanciated variable and you want to be able to modify this specific property by finding it with the name, am I right? – Error 404 Brain not found Nov 26 '21 at 13:32
  • @Error404Brainnotfound In a sense, yes. Its not as much a Property Name, but rather a public variable. I would like to find it with the string name and I've been battling Reflection for most of the day. Any pointers or advice would be greatly appreciated :)) – Sebastian van der Westhuizen Nov 26 '21 at 13:36
  • 1
    this is a pure C# issue, nothing to do with Xamarin – Jason Nov 26 '21 at 13:45
  • Unfortunately the question is closed i can't post an answer with code, but be sure to look at [the post](https://stackoverflow.com/questions/1196991/get-property-value-from-string-using-reflection) that has answers to this question :) – Error 404 Brain not found Nov 26 '21 at 14:09
  • 1
    Thank you so much @Error404Brainnotfound i really appreciate your time :)) Im going to try and find everything I can and hopefully solve this craziness. – Sebastian van der Westhuizen Nov 29 '21 at 07:43
  • @Jason its within a Xamarin project, just thought I would include it in the tag since more context could maybe have helped :) – Sebastian van der Westhuizen Nov 29 '21 at 07:44

0 Answers0