Get property value from string using reflection

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Get property value from string using reflection

Message par ForumBot »

Get property value from string using reflection
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Get property value from string using reflection

Message par ForumBot »

```
public static object GetPropValue(object src, string propName)
{
return src.GetType().GetProperty(propName).GetValue(src, null);
}

```

Of course, you will want to add validation and whatnot, but that is the gist of it.
Répondre

Revenir à « .NET & C# »