BasePropertyValueOrStringEmpty Method

A simple helper method that will return String.Empty if the specified string value is null. If not null, it returns the string value.

Definition

Namespace: EWSoftware.PDI.Properties
Assembly: EWSoftware.PDI.Data (in EWSoftware.PDI.Data.dll) Version: 2023.1.2.0
public static string ValueOrStringEmpty(
	string propertyValue
)

Parameters

propertyValue  String
The property value string to check

Return Value

String
The property value if not null or String.Empty if the value is null

Remarks

This may be useful if you would prefer not to have to always check for null values in string-type properties before using a string method that may throw an exception if it is null (i.e. Length).

Example

C#
string country = BaseProperty.ValueOrStringEmpty(vCard.Address.Country);

// No need to check for null first
if(country.Length != 0)
    // ... Do something with the country value ...

See Also