当前位置: 首页>>代码示例>>C#>>正文


C# Object.clone方法代码示例

本文整理汇总了C#中System.Object.clone方法的典型用法代码示例。如果您正苦于以下问题:C# Object.clone方法的具体用法?C# Object.clone怎么用?C# Object.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Object的用法示例。


在下文中一共展示了Object.clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getInstance

        /**
         * Transformer method that performs validation.
         *
         * @param paramTypes  the constructor parameter types
         * @param args  the constructor arguments
         * @return an instantiate transformer
         */
        public static Transformer getInstance(java.lang.Class[] paramTypes, Object[] args)
        {
            if (((paramTypes == null) && (args != null))
                || ((paramTypes != null) && (args == null))
                || ((paramTypes != null) && (args != null) && (paramTypes.Length != args.Length)))
            {
                throw new java.lang.IllegalArgumentException("Parameter types must match the arguments");
            }

            if (paramTypes == null || paramTypes.Length == 0)
            {
                return NO_ARG_INSTANCE;
            }
            else
            {
                paramTypes = (java.lang.Class[])paramTypes.clone();
                args = (Object[])args.clone();
            }
            return new InstantiateTransformer(paramTypes, args);
        }
开发者ID:gadfly,项目名称:nofs,代码行数:27,代码来源:org.apache.commons.collections.functors.InstantiateTransformer.cs

示例2: MultiKey

        /**
         * Constructor taking an array of keys, optionally choosing whether to clone.
         * <p>
         * <b>If the array is not cloned, then it must not be modified.</b>
         * <p>
         * This method is public for performance reasons only, to avoid a clone.
         * The hashcode is calculated once here in this method.
         * Therefore, changing the array passed in would not change the hashcode but
         * would change the equals method, which is a bug.
         * <p>
         * This is the only fully safe usage of this constructor, as the object array
         * is never made available in a variable:
         * <pre>
         * new MultiKey(new Object[] {...}, false);
         * </pre>
         * <p>
         * The keys should be immutable
         * If they are not then they must not be changed after adding to the MultiKey.
         *
         * @param keys  the array of keys, not null
         * @param makeClone  true to clone the array, false to assign it
         * @throws IllegalArgumentException if the key array is null
         * @since Commons Collections 3.1
         */
        public MultiKey(Object[] keys, bool makeClone)
            : base()
        {
            if (keys == null)
            {
                throw new java.lang.IllegalArgumentException("The array of keys must not be null");
            }
            if (makeClone)
            {
                this.keys = (Object[])keys.clone();
            }
            else
            {
                this.keys = keys;
            }

            int total = 0;
            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i] != null)
                {
                    total ^= keys[i].GetHashCode();
                }
            }
            hashCodeJ = total;
        }
开发者ID:gadfly,项目名称:nofs,代码行数:50,代码来源:org.apache.commons.collections.keyvalue.MultiKey.cs

示例3: getInstance

        /**
         * Factory method that performs validation.
         *
         * @param classToInstantiate  the class to instantiate, not null
         * @param paramTypes  the constructor parameter types
         * @param args  the constructor arguments
         * @return a new instantiate factory
         */
        public static Factory getInstance(java.lang.Class classToInstantiate, java.lang.Class[] paramTypes, Object[] args)
        {
            if (classToInstantiate == null)
            {
                throw new java.lang.IllegalArgumentException("Class to instantiate must not be null");
            }
            if (((paramTypes == null) && (args != null))
                || ((paramTypes != null) && (args == null))
                || ((paramTypes != null) && (args != null) && (paramTypes.Length != args.Length)))
            {
                throw new java.lang.IllegalArgumentException("Parameter types must match the arguments");
            }

            if (paramTypes == null || paramTypes.Length == 0)
            {
                return new InstantiateFactory(classToInstantiate);
            }
            else
            {
                paramTypes = (java.lang.Class[])paramTypes.clone();
                args = (Object[])args.clone();
                return new InstantiateFactory(classToInstantiate, paramTypes, args);
            }
        }
开发者ID:gadfly,项目名称:nofs,代码行数:32,代码来源:org.apache.commons.collections.functors.InstantiateFactory.cs


注:本文中的System.Object.clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。