本文整理汇总了C#中Library.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToArray方法的具体用法?C# List.ToArray怎么用?C# List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library.List
的用法示例。
在下文中一共展示了List.ToArray方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
public byte[] GetData()
{
List<byte> result = new List<byte>();
byte[] byteLabel = Encoding.ASCII.GetBytes(Label);
Writer.AddBytes(result, byteLabel);
foreach (Frame frame in Frames)
{
result.AddRange(frame.GetData());
}
return result.ToArray();
}
示例2: GetBrotherNodes
/// <summary>兄弟ノードを取得する。
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public static TreeNode[] GetBrotherNodes(this TreeNode node)
{
var broNodes = new List<TreeNode>();
for (var iNode = node.PrevNode; iNode != null; iNode = iNode.PrevNode)
{
broNodes.Add(iNode);
}
broNodes.Reverse();
for (var iNode = node.NextNode; iNode != null; iNode = iNode.NextNode)
{
broNodes.Add(iNode);
}
return broNodes.ToArray();
}
示例3: AddFiles
private List<int> AddFiles()
{
List<string> filenames = new List<string>();
List<string> filedescs = new List<string>();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
filenames.Add(dataGridView1.Rows[i].Cells[0].Value.ToString());
filedescs.Add(dataGridView1.Rows[i].Cells[1].Value.ToString());
}
AddMultiFilesMessage amfm = new AddMultiFilesMessage();
amfm.filenames = filenames.ToArray<string>();
amfm.filedescs = filedescs.ToArray<string>();
amfm.project = Project;
AddMultiFilesReturn idlist = client.AddMultiFiles(amfm);
btnUpload.Enabled = false;
lblError.Text = "Upload done";
return idlist.ids.ToList();
}
示例4: BufferManager
public BufferManager(long maxBufferPoolSize, int maxBufferSize)
{
//_bufferManager = System.ServiceModel.Channels.BufferManager.CreateBufferManager(maxBufferPoolSize, maxBufferSize);
if (maxBufferPoolSize < maxBufferSize) throw new ArgumentOutOfRangeException();
if (maxBufferPoolSize == 0) throw new ArgumentOutOfRangeException();
_maxBufferPoolSize = maxBufferPoolSize;
_maxBufferSize = maxBufferSize;
var sizes = new List<int>();
var buffers = new List<LinkedList<WeakReference>>();
for (int i = 256; i < _maxBufferSize; i *= 2)
{
sizes.Add(i);
buffers.Add(new LinkedList<WeakReference>());
}
_sizes = sizes.ToArray();
_buffers = buffers.ToArray();
_watchTimer = new System.Threading.Timer(this.WatchTimer, null, new TimeSpan(0, 0, 30), new TimeSpan(0, 0, 30));
}
示例5: comPort_DataReceived
// Data Received Delegate Trigger
void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
//Thread.Sleep(2000);
//byte[] ReadSerialData = new byte[comPort.BytesToRead];
//string TotalSerialData = "";
//string stringData = "";
List<byte> ListByte = new List<byte>();
byte[] ReadSerialData;
do
{
int numOfBytes = comPort.BytesToRead;
ReadSerialData = new byte[numOfBytes];
comPort.Read(ReadSerialData, 0, numOfBytes);
ListByte.AddRange(ReadSerialData);
//stringData = Encoding.UTF8.GetString(ReadSerialData, 0, numOfBytes);
//TotalSerialData = TotalSerialData + stringData;
PauseForMilliSeconds(40);
} while (comPort.BytesToRead > 0);
//do
//{
// Byte ReadSerialData1;
// ReadSerialData1 = (byte)comPort.ReadByte();
// ListByte.Add(ReadSerialData1);
//} while (comPort.BytesToRead > 0);
if (ListByte[ListByte.Count - 2] == 0x0d)
{
if (ListByte[ListByte.Count - 1] == 0x0a)
{
Console.WriteLine("True");
WriteEOT();
}
}
ReadSerialData = new byte[ListByte.Count];
ReadSerialData = ListByte.ToArray();
//do
//{
//int numOfBytes = comPort.BytesToRead;
//ReadSerialData = new byte[numOfBytes];
//stringData = comPort.ReadTo("\r\n");
////stringData = Encoding.UTF8.GetString(ReadSerialData, 0, numOfBytes);
//TotalSerialData = TotalSerialData + stringData;
//PauseForMilliSeconds(200);
//} while (comPort.BytesToRead > 0);
//byte[] ReadSerialData = new byte[comPort.BytesToRead];
//comPort.Read(ReadSerialData, 0, ReadSerialData.Length);
if (SerialDataReceived != null)
{
SerialDataReceived((ReadSerialData));
}
}
catch //(Exception ex)
{
throw;
}
}
示例6: WriteEOT
public void WriteEOT()
{
try
{
if (comPort.IsOpen == true)
{
comPort.DiscardInBuffer();
comPort.DiscardOutBuffer();
//byte returnbyte = 4;
List<byte> list = new List<byte>();
//EOT
list.Add(4);
//Dash
list.Add(226);
//Hashtag
//list.Add(35);
//ACK
list.Add(6);
// !A
//list.Add(33);
//list.Add(65);
byte[] bytearr = new byte[list.Count];
bytearr = list.ToArray();
//byte[] bytearr = new byte[1];
//bytearr = Encoding.UTF8.GetBytes("!A");
//bytearr = BitConverter.GetBytes(returnbyte);
comPort.Write(bytearr, 0, bytearr.Length);
}
}
catch //(Exception ex)
{
throw;
}
}
示例7: WriteCLREEPROM
public void WriteCLREEPROM()
{
try
{
comPort.DataReceived -= new SerialDataReceivedEventHandler(comPort_DataReceived);
if (comPort.IsOpen == true)
{
comPort.DiscardInBuffer();
comPort.DiscardOutBuffer();
//byte returnbyte = 4;
List<byte> list = new List<byte>();
// !A
list.Add(33);
list.Add(65);
byte[] bytearr = new byte[list.Count];
bytearr = list.ToArray();
//byte[] bytearr = new byte[1];
//bytearr = Encoding.UTF8.GetBytes("!A");
//bytearr = BitConverter.GetBytes(returnbyte);
comPort.Write(bytearr, 0, bytearr.Length);
}
}
catch
{
throw;
}
}
示例8: TransAddMsgTxt
//自定义附加消息显示 周立山 2014.1.3
private string[] TransAddMsgTxt(string addMsgTxt)
{
List<string> results = new List<string>();
try
{
//addMsgTxt = "10/M100000/20/ME8A8";
string[] addmsgtxts = addMsgTxt.Split('/');
foreach (string s in addmsgtxts)
{
if (!s.StartsWith("ME8"))
continue;
byte byt = Convert.ToByte(s.Substring(3), 16);
if ((byt & 128) != 0)
results.Add("制动/开");
else
results.Add("制动/关");
if ((byt & 64) != 0)
results.Add("左转向灯/开");
else
results.Add("左转向灯/关");
if ((byt & 32) != 0)
results.Add("右转向灯/开");
else
results.Add("右转向灯/关");
if ((byt & 16) != 0)
results.Add("远光灯/开");
else
results.Add("远光灯/关");
if ((byt & 8) != 0)
results.Add("近光灯/开");
else
results.Add("近光灯/关");
}
}
catch
{
//Record.execFileRecord("自定义附加消息时失败!");
}
return results.ToArray();
}
示例9: GetDescendants
/// <summary>子孫ノードを取得する。
/// </summary>
/// <param name="nodes">ツリーノードのコレクション。</param>
/// <returns>子孫ノードの配列。</returns>
public static TreeNode[] GetDescendants(this TreeNodeCollection nodes)
{
var list = new List<TreeNode>();
TreeViewUtility.GetDescendants(nodes, list);
return list.ToArray();
}
示例10: TestFilters
private static bool TestFilters()
{
List<byte> values = new List<byte>() { 1, 2, 3, 5 };
List<byte> original = new List<byte>(values);
ColorBitPlaneChunk.Filter(values);
Console.Write("Have filtered values");
foreach (byte b in values)
{
Console.Write(" " + b);
}
Console.WriteLine(string.Empty);
byte[] array = values.ToArray();
ColorBitPlaneChunk.UnFilter(array);
int index = 0;
foreach (byte b in original)
{
if (array[index] != b)
{
Console.WriteLine("Failed match in index " + index + " have original " + b + " and got instead " + array[index]);
return false;
}
index++;
}
return true;
}
示例11: ConvertBytesToBools
/// <summary>
/// There's probably a better way to do this
/// </summary>
/// <param name="bytes"></param>
/// <param name="size"></param>
/// <returns></returns>
public static bool[] ConvertBytesToBools(byte[] bytes, int size)
{
List<bool> result = new List<bool>();
int index = 0;
for (int i = 0; i < bytes.Length; i++)
{
//read a bytes worth of bits at a time
for (int j = 0; j < Writer.Masks.Length; j++)
{
byte b = bytes[i];
bool boolean = (b & Writer.Masks[j]) != 0;
result.Add(boolean);
index++;
if (index >= size)
{
return result.ToArray();
}
}
}
//oops
throw new Exception("Failed to convert Bytes to Bools");
}
示例12: Write
public byte[] Write(Frame frame)
{
List<byte> result = new List<byte>();
foreach (Chunk chunk in frame.Chunks)
{
}
return result.ToArray();
}
示例13: GetData
public byte[] GetData()
{
List<byte> result = new List<byte>();
byte[] byteLabel = Encoding.ASCII.GetBytes(Label);
Writer.AddBytes(result, byteLabel);
foreach (Chunk chunk in Chunks)
{
result.AddRange(chunk.GetData());
}
//don't forget the size
Writer.WriteSizeInt(result);
return result.ToArray();
}