Skip to content

Instantly share code, notes, and snippets.

View daviddpatrick's full-sized avatar

David Patrick daviddpatrick

View GitHub Profile
@daviddpatrick
daviddpatrick / UppercaseProperties.cs
Last active June 4, 2020 00:40
Set strings properties in object to uppercase with reflection in c#
var obj = new Class();
obj.GetType().GetProperties().ForEach(p =>
{
if (p.PropertyType == typeof(string) && p.GetValue(obj) != null)
p.SetValue(obj, p.GetValue(obj).ToString().ToUpper());
});