System.Globalization.DateTimeFormatInfo.Clone C# (CSharp) Method

Clone() public method

Creates a shallow copy of the DateTimeFormatInfo.
public Clone ( ) : object
return object
        public extern object Clone();

Usage Example

Esempio n. 1
0
        /// <include file='doc\CultureInfo.uex' path='docs/doc[@for="CultureInfo.Clone"]/*' />
        public virtual Object Clone()
        {
            CultureInfo ci = (CultureInfo)MemberwiseClone();

            //If this is exactly our type, we can make certain optimizations so that we don't allocate NumberFormatInfo or DTFI unless
            //they've already been allocated.  If this is a derived type, we'll take a more generic codepath.
            if (ci.GetType() == typeof(CultureInfo))
            {
                if (dateTimeInfo != null)
                {
                    ci.dateTimeInfo = (DateTimeFormatInfo)dateTimeInfo.Clone();
                }
                if (numInfo != null)
                {
                    ci.numInfo = (NumberFormatInfo)numInfo.Clone();
                }
                ci.m_isReadOnly = false;
            }
            else
            {
                ci.m_isReadOnly   = false;
                ci.DateTimeFormat = (DateTimeFormatInfo)this.DateTimeFormat.Clone();
                ci.NumberFormat   = (NumberFormatInfo)this.NumberFormat.Clone();
            }
            return(ci);
        }
All Usage Examples Of System.Globalization.DateTimeFormatInfo::Clone