Properties, classes, and schemas have display labels and names. Display labels can contain any combination of unicode characters. Names are restricted by a very specific set of rules. It would be very inefficient for APIs like GetPropertyValue() to have to convert from display label to internal name, and also ambiguous (you can have a property named "X" and another unrelated property with the display label "X").
ECNameValidation.EncodeToValidName() takes a display label and converts it to a valid EC name (replacing all non-alphanumeric characters with a __x****__ string, fixing up leading digits, etc). That is what Item Types uses to generate property names, so if you know you have an Item Type property you can use it too. (However you cannot assume in the general case that property name == encoded display label).
Alternatively you can use CustomProperty.InternalName to get the property name.
Either way, manually replacing spaces with __x0020__ will not suffice.
HTH,
Paul
ECNameValidation.EncodeToValidName() takes a display label and converts it to a valid EC name (replacing all non-alphanumeric characters with a __x****__ string, fixing up leading digits, etc). That is what Item Types uses to generate property names, so if you know you have an Item Type property you can use it too. (However you cannot assume in the general case that property name == encoded display label).
Alternatively you can use CustomProperty.InternalName to get the property name.
Either way, manually replacing spaces with __x0020__ will not suffice.
HTH,
Paul