Answers for "check property type of collection c#"

C#
0

check property type of collection c#

var obj = new PropClassDemo();
foreach (PropertyInfo prop in obj.GetType().GetProperties())
{
	if(prop.PropertyType != typeof(string) && typeof(IEnumerable).IsAssignableFrom(prop.PropertyType))
	{
		Console.Writeline("This prop's type is Ienumerable");
	}
}

//Note: string is an ienumerable too
Posted by: Guest on July-08-2020

C# Answers by Framework

Browse Popular Code Answers by Language