本文整理汇总了C#中System.Collections.Generic.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.ToArray方法的具体用法?C# System.Collections.Generic.List.ToArray怎么用?C# System.Collections.Generic.List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasCast
private static bool HasCast(Type type, Type from, Type to, out MethodInfo op)
{
#if WINRT
System.Collections.Generic.List<MethodInfo> list = new System.Collections.Generic.List<MethodInfo>();
foreach (var item in type.GetRuntimeMethods())
{
if (item.IsStatic) list.Add(item);
}
MethodInfo[] found = list.ToArray();
#else
const BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
MethodInfo[] found = type.GetMethods(flags);
#endif
for(int i = 0 ; i < found.Length ; i++)
{
MethodInfo m = found[i];
if ((m.Name != "op_Implicit" && m.Name != "op_Explicit") || m.ReturnType != to)
{
continue;
}
ParameterInfo[] paramTypes = m.GetParameters();
if(paramTypes.Length == 1 && paramTypes[0].ParameterType == from)
{
op = m;
return true;
}
}
op = null;
return false;
}
示例2: unit
static MItem unit(string Format, params string[] units)
{
var lUnits = new System.Collections.Generic.List<string>(units.Length);
foreach (var unit in units)
lUnits.Add(SMath.Manager.UnitsManager.GetCurrentUnitName(unit));
return Converter.ToMItem(string.Format(Format, lUnits.ToArray()));
}
示例3: Start
// Use this for initialization
void Start()
{
buffSpawnPositions = GetComponentsInChildren<Transform> ();
System.Collections.Generic.List<Transform> list = new System.Collections.Generic.List<Transform> (buffSpawnPositions);
list.Remove (transform);
buffSpawnPositions = list.ToArray ();
}
示例4: SubReader
/// <summary> Returns sub-reader subIndex from reader.
///
/// </summary>
/// <param name="reader">parent reader
/// </param>
/// <param name="subIndex">index of desired sub reader
/// </param>
/// <returns> the subreader at subINdex
/// </returns>
public static IndexReader SubReader(IndexReader reader, int subIndex)
{
var subReadersList = new System.Collections.Generic.List<IndexReader>();
ReaderUtil.GatherSubReaders(subReadersList, reader);
IndexReader[] subReaders = subReadersList.ToArray();
return subReaders[subIndex];
}
示例5: RandomTest
public void RandomTest()
{
RingBuffer<int> TestObject = new RingBuffer<int>(10);
Utilities.Random.Random Rand = new Utilities.Random.Random();
int Value = 0;
for (int x = 0; x < 10; ++x)
{
Value = Rand.Next();
TestObject.Add(Value);
Assert.Equal(1, TestObject.Count);
Assert.Equal(Value, TestObject.Remove());
}
Assert.Equal(0, TestObject.Count);
System.Collections.Generic.List<int> Values=new System.Collections.Generic.List<int>();
for (int x = 0; x < 10; ++x)
{
Values.Add(Rand.Next());
}
TestObject.Add(Values);
Assert.Equal(Values.ToArray(), TestObject.ToArray());
for (int x = 0; x < 10; ++x)
{
Assert.Throws<InvalidOperationException>(() => TestObject.Add(Rand.Next()));
Assert.Equal(10, TestObject.Count);
}
}
示例6: ReadZeroTerminatedString
private static string ReadZeroTerminatedString(Stream stream)
{
byte[] buf1 = new byte[1];
var list = new System.Collections.Generic.List<byte>();
bool done = false;
do
{
// workitem 7740
int n = stream.Read(buf1, 0, 1);
if (n != 1)
{
throw new ZlibException("Unexpected EOF reading GZIP header.");
}
if (buf1[0] == 0)
{
done = true;
}
else
{
list.Add(buf1[0]);
}
} while (!done);
byte[] a = list.ToArray();
return ArchiveEncoding.Default.GetString(a, 0, a.Length);
}
示例7: BlockTag
private void BlockTag(string tag, IDictionary attributes, ICallable block)
{
Output.Write("<{0}", tag);
System.Collections.Generic.List<string> attributeValues = new System.Collections.Generic.List<string>();
if (null != attributes)
{
foreach(DictionaryEntry entry in attributes)
{
attributeValues.Add(string.Format("{0}=\"{1}\"", entry.Key, entry.Value));
}
}
if (0 != attributeValues.Count)
{
Output.Write(" ");
Output.Write(string.Join(" ", attributeValues.ToArray()));
}
Output.Write(">");
if (block != null)
{
block.Call(null);
}
Output.Write("</{0}>", tag);
}
示例8: _Export
void _Export(string path,GameObject obj)
{
var bcs = obj.GetComponentsInChildren<BoxCollider>();
System.Collections.Generic.List<Regulus.Utility.OBB> obbs = new System.Collections.Generic.List<Regulus.Utility.OBB>();
foreach (var bc in bcs)
{
float x = bc.gameObject.transform.position.x;
//float x = bc.bounds.center.x;
float y = bc.gameObject.transform.position.z;
//float y = bc.bounds.center.z;
float w = bc.gameObject.transform.localScale.x * bc.size.x;
//float w = bc.bounds.size.x;
float h = bc.gameObject.transform.localScale.z * bc.size.z;
//float h = bc.bounds.size.z;
float r = bc.gameObject.transform.rotation.eulerAngles.y;
Debug.Log("x" + x + " " + "y" + y + " " + "w" + w + " " + "h" + h + " " + "r" + r + " ");
var obb = new Regulus.Utility.OBB(x,y,w,h);
obb.setRotation(r);
obbs.Add(obb);
}
Debug.Log("Expoty obb count : " + obbs.Count );
Regulus.Utility.OBB.Write(path, obbs.ToArray());
}
示例9: GetErrors
ErrorInfo[] GetErrors (Document doc)
{
System.Collections.Generic.List<ErrorInfo> list = new System.Collections.Generic.List<ErrorInfo> ();
foreach (ParserException pe in doc.ParseErrors)
list.Add (new ErrorInfo (pe.Line, pe.Column, pe.Message));
return list.Count == 0? null : list.ToArray ();
}
示例10: BuildUri
internal override string BuildUri(string baseUri, string accesskey)
{
// assume no batch id nor events
string usingBatch = String.Empty;
string usingEvents = String.Empty;
// if the user has passed a batch id, build that portion of the query string request
if (!String.IsNullOrEmpty(BatchId))
{
usingBatch = String.Format("&batchid={0}", HttpUtility.UrlEncode(BatchId));
}
// if the user has passed event ids, build that portion of the query string request
if (EventIds != null)
{
if (EventIds.Count() != 0)
{
// URLEncode each event id
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
foreach (var ev in EventIds)
{
list.Add(HttpUtility.UrlEncode(ev));
}
// Build the event ids string
string idString = String.Join("_", list.ToArray());
usingEvents = String.Format("&eventids={0}", idString);
}
}
// build the uri
return String.Concat(baseUri, String.Format(c_removeeventscommand, accesskey, usingBatch, usingEvents));
}
示例11: AttrToString
private static string AttrToString(object attr)
{
object multivaluedAttribute = attr;
if (!(multivaluedAttribute is IEnumerable) || multivaluedAttribute is byte[] || multivaluedAttribute is string)
multivaluedAttribute = new Object[1] { multivaluedAttribute };
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
foreach (object attribute in (IEnumerable)multivaluedAttribute)
{
if (attribute == null)
{
list.Add(string.Empty);
}
else if (attribute is byte[])
{
byte[] bytes = (byte[])attribute;
list.Add(BytesToString(bytes));
}
else
{
list.Add(attribute.ToString());
}
}
return string.Join("|", list.ToArray());
}
示例12: GetRefreshRates
public static int[] GetRefreshRates(int width, int height) {
System.Collections.Generic.List<int> rates=new System.Collections.Generic.List<int>();
foreach(DisplayMode ds in d3d.Adapters[adapter].GetDisplayModes(Format.X8R8G8B8)) {
if(ds.Width==width && ds.Height==height) rates.Add(ds.RefreshRate);
}
return rates.ToArray();
}
示例13: CreateInstanceData
protected override Neo.ApplicationFramework.Common.Alias.Entities.AliasInstancesCF CreateInstanceData()
{
System.Collections.Generic.List<Neo.ApplicationFramework.Common.Alias.Entities.AliasInstanceCF> instanceList = new System.Collections.Generic.List<Neo.ApplicationFramework.Common.Alias.Entities.AliasInstanceCF>(1);
instanceList.Add(this.CreateInstanceData_Default());
Neo.ApplicationFramework.Common.Alias.Entities.AliasInstancesCF aliasInstances = new Neo.ApplicationFramework.Common.Alias.Entities.AliasInstancesCF();
aliasInstances.Instances = instanceList.ToArray();
return aliasInstances;
}
示例14: ToBytes
public byte[] ToBytes()
{
System.Collections.Generic.List<byte> dataBuffer = new System.Collections.Generic.List<byte>();
dataBuffer.AddRange(TypeMarshal.ToBytes<ushort>((ushort)(this.BlockT.blockType)));
dataBuffer.AddRange(TypeMarshal.ToBytes<uint>(this.BlockT.blockLen));
dataBuffer.AddRange(TypeMarshal.ToBytes<byte>(this.numChannels));
dataBuffer.AddRange(TypeMarshal.ToBytes<TS_RFX_CHANNELT>(this.channels[0]));
return dataBuffer.ToArray();
}
示例15: GetRange
/// <summary>
/// Gets values from range
/// </summary>
/// <param name="fromIndex">int - startindex - including</param>
/// <param name="toIndex">int - stop index - including</param>
/// <returns>double[] - values from given range</returns>
public double[] GetRange(int fromIndex, int toIndex)
{
System.Collections.Generic.List<double> values = new System.Collections.Generic.List<double>();
for (int i = fromIndex; i <= toIndex; i++)
{
values.Add(this.Data[0][i]);
}
return values.ToArray();
}