Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
linq test
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Text; using System.Net; namespace Rextester { public class Program { public enum RequestType { None=0, Message=1, Command=2 } public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); int length=0x12345678; length = System.Net.IPAddress.HostToNetworkOrder(length); var bytes = BitConverter.GetBytes(length); bytes = bytes.Concat(new byte[]{0x09,0x0a}).ToArray(); Console.WriteLine("{0:x},{1:x},{2:x},{3:x},{4:x}",bytes[0],bytes[1],bytes[2],bytes[3],bytes[4]); int _type = 0x12345678, _dataLength=8; byte[] _data =new byte[0];// Encoding.UTF8.GetBytes("ABCDEFGH"); var type = BitConverter.IsLittleEndian ? IPAddress.HostToNetworkOrder(_type) : _type; var dataLength = BitConverter.IsLittleEndian ? IPAddress.HostToNetworkOrder(_dataLength) : _dataLength; var bytes2 = BitConverter.GetBytes(type).Concat(BitConverter.GetBytes(dataLength)).Concat(_data); foreach(var b in bytes2) { Console.WriteLine("{0:x}",b); } //SelectVsSelectMany(); //string data=null; //Encoding.UTF8.GetBytes(data); if((int)RequestType.Command==2) { } } static void SelectVsSelectMany() { List<Bouquet> bouquets = new List<Bouquet>() { new Bouquet { Flowers = new List<string> { "sunflower", "daisy", "daffodil", "larkspur" }}, new Bouquet{ Flowers = new List<string> { "tulip", "rose", "orchid" }}, new Bouquet{ Flowers = new List<string> { "gladiolis", "lily", "snapdragon", "aster", "protea" }}, new Bouquet{ Flowers = new List<string> { "larkspur", "lilac", "iris", "dahlia" }} }; // *********** Select *********** IEnumerable<List<string>> query1 = bouquets.Select(bq => bq.Flowers); // ********* SelectMany ********* IEnumerable<string> query2 = bouquets.SelectMany(bq => bq.Flowers); Console.WriteLine("Results by using Select():"); // Note the extra foreach loop here. foreach (IEnumerable<String> collection in query1) foreach (string item in collection) Console.WriteLine(item); Console.WriteLine("\nResults by using SelectMany():"); foreach (string item in query2) Console.WriteLine(item); } } class Bouquet { public List<string> Flowers { get; set; } } }
run
|
edit
|
history
|
help
0
Project Euler Problem 7
Found many section of times intersect.
divisão
Par ou ímpar input
Zadanka
test 1
ö2
Timer2
D12
Pizzas&Tuples&Golden-Medal