First off, let’s talk about what’s going on in C# compiler when you use const or readonly in your field definitions. The const qualifier can be used with primitive data types, and strings only. When used, the value assigned to a const field, is inserted directly in all its references in the generated IL code. This is true about other assemblies too. Other assemblies that refer to that const field, are compiled as if they have used directly the value itself.
Suppose that you have a class with various non-public fields, e.g., the class named ClassToTest below servers as a good example.
public class ClassToTest { public int SomeNumber { get; set; } private int m_somePrivateProperty { get; set; } private int m_somePrivateVar; private static int s_someStaticNumber; } And suppose that we desire to assign some value to the private variable m_somePrivateVar, and the private property m_somePrivateProperty. The approach is to iterate through the fields of the ClassToTest type to find the desired field.