<p>This is what I have written:</p>

<pre><code>if ((lstProperty[i].PropertyIdentifier as string).CompareTo("Name") == 0)
</code></pre>

<p>Resharper put me an error (I am new with ReSharper... I am trying it) and it suggests me :</p>

<pre><code>  if (((string) lstProperty[i].PropertyIdentifier).CompareTo("Name") == 0)
</code></pre>

<p>Why is the second is NullException safe? For me both will crash if null value appear?</p>

The 'as' operator will return null if the cast cannot be executed, while a C-style cast will throw an exception if it can't cast.
I suggest breaking this out into multiple statements:
```
```
string propertyIdentifier = lstProperty[u].PropertyIdentifier as string;
if(propertyIdentifier != null && propertyIdentifier.CompareTo("Name") == 0)
{
    ... your if statement ...
}
```
```
Resharper shouldn't complain about this, and you also won't get a NullReferenceException if the PropertyIdentifier is null or not a string.