Question: How do I determine if a property is a user-defined type? I tried to use IsClass as shown below but its value was true for String properties (and who knows what else).

```
foreach (var property in type.GetProperties()) {
    if (property.PropertyType.IsClass) {
        // do something with property
    }
}

```

**\* Updated for more clarity \***

I am trying to traverse a given type's definition and if the given type or any of its public properties are defined within the assembly, I am searching for an embedded JavaScript document. I just don't want to waste processing resources and time on native .NET types.

Answer: 
If by "user-defined" you mean that it is not part of the standard assembly (mscorlib) then you can do something along the lines of this:

```
if(typeof(SomeType).Assembly.GetName().Name != "mscorlib") {
    // user-defined!
}

```

However this will also consider types from external assemblies (aka: libraries) to be considered "user-defined". If you only want those in your current assembly then you can use

```
typeof(SomeType).Assembly == Assembly.GetExecutingAssembly()

```
I struggled with this as well when creating a log when updating the database. I did not want the classes to be shown in the log as they never == between data and dto.

```
foreach (PropertyType item in properties)
{
    if((item.PropertyType.IsClass && item.PropertyType.FullName.StartsWith("System.")) || !item.PropertyType.IsClass)
    {
       //...do stuff
    }
}

```

This allowed me to deal with strings and the likes which are flagged as classes.