Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Thanks to everyone who gave advice, in the end the following design worked:
public class M2
{
public string str { get; set; }
public List<string> GetNames()
{
return GetType().GetProperties().Select(x => x.Name).ToList();
}
}
Something like this: https://stackoverflow.com/questions/237275/how-can...
Type type = obj.GetType();
foreach (var f in type.GetFields().Where(f => f.IsPublic)) {
Console.WriteLine(
String.Format("Name: {0} Value: {1}", f.Name, f.GetValue(obj));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question