Base PropertyValue Or String Empty 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: 2025.1.9.0
The property value if not null or String.Empty if the value is null
Assembly: EWSoftware.PDI.Data (in EWSoftware.PDI.Data.dll) Version: 2025.1.9.0
C#
public static string ValueOrStringEmpty(
string propertyValue
)VB
Public Shared Function ValueOrStringEmpty (
propertyValue As String
) As StringC++
public:
static String^ ValueOrStringEmpty(
String^ propertyValue
)F#
static member ValueOrStringEmpty :
propertyValue : string -> string Parameters
- propertyValue String
- The property value string to check
Return Value
StringThe 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 ...VB
Dim country As String = BaseProperty.ValueOrStringEmpty(vCard.Address.Country)
' No need to check for null first
If country.Length <> 0 Then
' ... Do something with the country value ...
End IfC++
No code example is currently available or this language may not be supported.F#
No code example is currently available or this language may not be supported.