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


C# Object.ToList方法代码示例

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


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

示例1: ParseDefaultValue

 public object ParseDefaultValue(INamedParameterNode name)
 {
     string[] vals = name.GetDefaultInstanceAsStrings();
     object[] ret = new Object[vals.Length];
     for (int i = 0; i < vals.Length; i++)
     {
         string val = vals[i];
         try
         {
             ret[i] = Parse(name, val);
         }
         catch (ParseException e)
         {
             Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
             var ex = new ClassHierarchyException("Could not parse default value " + val, e);
             Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
         }
     }
     if (name.IsSet())
     {
         return new HashSet<object>(ret.ToList<object>());
     }
     if (name.IsList())
     {
         return new List<object>(ret.ToList<object>());
     }
     if (ret.Length == 0)
     {
         return null;
     }
     if (ret.Length == 1)
     {
         return ret[0];
     }
     var ec = new IllegalStateException("Multiple defaults for non-set named parameter! " + name.GetFullName());
     Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ec, LOGGER);
     return null; //this line would be never reached as Throw will throw an exception
 }
开发者ID:jsryu21,项目名称:incubator-reef,代码行数:38,代码来源:ClassHierarchyImpl.cs

示例2: ParseDefaultValue

 public object ParseDefaultValue(INamedParameterNode name)
 {
     string[] vals = name.GetDefaultInstanceAsStrings();
     object[] ret = new Object[vals.Length];
     for (int i = 0; i < vals.Length; i++)
     {
         string val = vals[i];
         try
         {
             ret[i] = Parse(name, val);
         }
         catch (ParseException e)
         {
             throw new ClassHierarchyException("Could not parse default value", e);
         }
     }
     if (name.IsSet())
     {
         return new HashSet<object>(ret.ToList<object>());
     }
     else
     {
         if (ret.Length == 0)
         {
             return null;
         }
         else if (ret.Length == 1)
         {
             return ret[0];
         }
         else
         {
             throw new IllegalStateException("Multiple defaults for non-set named parameter! " + name.GetFullName());
         }
     }
 }
开发者ID:kyungtaak,项目名称:TANG,代码行数:36,代码来源:ClassHierarchyImpl.cs

示例3: splitData

        /// <summary>
        /// Splite and prepare data source for thread-workers
        /// </summary>
        protected void splitData()
        {
            //counters
            int toUse = 0, alreadyUsed = 0;
            int dataCount = m_data.Count;

            //split data
            for (int i = 0; i < m_workCounts; i++)
            {
                toUse = ((i + 1) * dataCount) / m_workCounts - alreadyUsed;

                Object[] workArr = new Object[toUse];
                m_data.CopyTo(alreadyUsed, workArr, 0, toUse);
                m_workers[i].setImput(workArr.ToList<Object>());

                alreadyUsed += toUse;
            }
        }
开发者ID:ExShini,项目名称:workRep,代码行数:21,代码来源:ThreadController.cs


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