本文整理汇总了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
}
示例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());
}
}
}
示例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;
}
}