Voglio passare attraverso tutte le proprietà di un tipo e voglio controllare se un tipo di proprietà non è una stringa, come posso farlo?Come verificare se un tipo è una stringa in C#?
La mia classe è:
public class MarkerInfo
{
public string Name { get; set; }
public byte[] Color { get; set; }
public TypeId Type { get; set; }
public bool IsGUIVisible { get; set; }
public MarkerInfo()
{
Color = new byte[4]; // A, R, G, B
IsGUIVisible = true;
}
}
e il codice che sto usando per verificare la presenza di tipo è:
foreach (var property in typeof(MarkerInfo).GetProperties())
{
if (property.PropertyType is typeof(string))
}
Ma questo codice non funziona, qualsiasi idea di come farlo?