Get property value from string using reflection

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Get property value from string using reflection

Message par Clippy »

Get property value from string using reflection
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: Get property value from string using reflection

Message par Clippy »

```
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# »