I have one class that inherits another. I want to use reflection to cycle through the properties and write the values to a file. No problem. Except that I want to control the order in which the properties write out. Is there a clean way to do this? Right now, problem 1 is that the properties in the the subclass write out and THEN the proepries in the parent class write out. But also, I may want to skip some properties or just reorder them.
Here is my code now...
foreach (PropertyInfo bp in t.GetProperties())
{
Type pt = bp.PropertyType;
if ((pt.IsArray) && pt.FullName == "System.Char[]")
{
char[] caPropertyValue;
caPropertyValue = (char[])(bp.GetValue(oBatch, null));
string strPropertyValue = new string(caPropertyValue);
myBatch.Add(strPropertyValue);
}
}