Returns suffixed if value is present. Else returns empty string. - CSharp System

CSharp examples for System:String SubString

Description

Returns suffixed if value is present. Else returns empty string.

Demo Code


using System;// w  ww  . j  a v a  2s.c o m

public class Main{
        /// <summary>
        /// Returns suffixed if value is present. Else returns empty string.
        /// </summary>
        public
        static
        string
        AppendIfIs(
            this string value,
            string suffix)
        {
            return value.Is()
                        ? value + suffix
                        : String.Empty;
        }
        /// <summary>
        /// Returns true if string is NOT (null or empty)
        /// </summary>
        public static bool Is(this string source)
        {
            return !String.IsNullOrEmpty(source);
        }
}

Related Tutorials