To retrieve the string from Object. - CSharp System

CSharp examples for System:Object

Description

To retrieve the string from Object.

Demo Code


using System.Xml.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System.IO;//w  ww  .  j  av a2  s.c  o  m
using System.Globalization;
using System.Collections.Generic;
using System;

public class Main{
        /// <summary>
        /// To retrieve the string.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static String ToStringOrEmpty(Object value)
        {
            if (value == null)
            {
                return "";
            }
            return value.ToString();
        }
        /// <summary>
        /// To retrieve the string. If the NULL will return an empty string.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static String ToString(Object value)
        {
            return ToStringOrEmpty(value);
        }
}

Related Tutorials