using System.Diagnostics;
public int MyProperty { get; set; }
public int a { get; set; }
public class DerivedClass : BaseClass
public new string MyProperty { get; set; }
public int b { get; set; }
Type type = typeof(DerivedClass);
string path = "MyProperty";
Stopwatch stopwatch1 = Stopwatch.StartNew();
for (int i = 0; i < iterations; i++)
PropertyInfo[] infos = type.GetProperties();
PropertyInfo info = infos.FirstOrDefault(p => p.Name.Equals(path, StringComparison.OrdinalIgnoreCase));
Console.WriteLine($"First code snippet time: {stopwatch1.ElapsedMilliseconds} ms");
Stopwatch stopwatch2 = Stopwatch.StartNew();
for (int i = 0; i < iterations; i++)
PropertyInfo info = null;
info = type.GetProperty(path);
catch (AmbiguousMatchException)
info = type.GetProperty(path, BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
Console.WriteLine($"Second code snippet time: {stopwatch2.ElapsedMilliseconds} ms");