2013-10-10 代码笔记

```cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("1380094216 = {0}", new DateTime(((long)(1380094216) * (long)(10000000)), DateTimeKind.Utc).ToLocalTime().AddYears(1969));
            Console.WriteLine(Convert.ToDateTime("1970-1-1 00:00:00").Ticks / 10000000);//Ticks为百纳秒数,Sticks/10000000是毫秒数

            var list = Enumerable.Range(1, 7);

            foreach (var item in list)
            {
                Console.Write("{0}\t", item);
            }
            
            var arr = list.ToArray();
            var result = new int[6];
   
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new Random(i).Next(1, 7);
            }

            Console.WriteLine("\n-------------------------------");

            for (int i = 0; i < result.Length; i++)
            {
                Console.Write("{0}\t", result[i]);
            }
            Console.WriteLine("\n-------------------------------");
            var query = Enumerable.Range(1, 7).OrderBy(x => Guid.NewGuid());
            var seq = Enumerable.Range(1, 7).OrderBy(x => Guid.NewGuid()).Take(6);
            foreach (var item in seq)
            {
                Console.Write("{0}\t", item);
            }

            Console.WriteLine("\n-------------------------------");

            var query2 = from x in arr

                    from y in arr

                    where y > x

                    select string.Format("{0}{1}", x, y);

            foreach (string item in query2)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\n-------------------------------");

            var query3 = from x in arr

                         from y in arr

                         where y < x

                         select string.Format("{0}{1}", x, y);

            foreach (string item in query3)
            {
                Console.WriteLine(item);
            }

            Console.ReadKey(true);
            
        }
    }
}


```

posted @ 2013-10-10 16:58  常伟华  阅读(277)  评论(0编辑  收藏  举报