前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >c# list<T>操作实例

c# list<T>操作实例

作者头像
zls365
发布2020-08-19 11:06:34
发布2020-08-19 11:06:34
88600
代码可运行
举报
文章被收录于专栏:CSharp编程大全CSharp编程大全
运行总次数:0
代码可运行
代码语言:javascript
代码运行次数:0
运行
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
             List<string[]> str1 = new List<string[]> { };
             List<string[]> str2 = new List<string[]> { };
             string[] class1 = { "牛连山", "数学成绩", "58" };
             string[] class2 = { "孙少华", "数学成绩", "37" };
             string[] class3 = { "蒋大帅", "数学成绩", "45" };
             string[] class4 = new string[20];
             //str1.AddRange(str2);
             str1.Add(class1);
             str1.Add(class2);
             str1.Add(class3);
             Console.WriteLine("输出1:"+str1.Count());//结果是3
             Console.WriteLine("输出2:"+str1[0][0]);
             Console.WriteLine("输出3:"+(str1.OrderBy(s => s[2]).ToList())[2][2]);
       

            List<string> lists = new List<string> { };
            lists.Add("str");
            lists.Add("hello");
            string[] str = lists.ToArray();
            foreach(string aa in str)
            {
                Console.WriteLine(aa);
            }

            List<byte[]> byt1 = new List<byte[]> { };
            List<byte[]> byt2 = new List<byte[]> { };
            List<byte> byt3 = new List<byte> { };
            byte[] by1 = { 0x11, 0x03, 0x05 ,0x24};
            byte[] by2 = { 0xA9, 0x01, 0x56 };
            byte[] by3 = { 0x04, 0x02, 0x07 };
            byte[,] by4 = new byte[9,2];
            byte[] by5 = new byte[9];
            byte zijie;
            byt1.Add(by1);
            byt1.Add(by2);
            byt1.Add(by3);
            byt2.Add(by1);

            Console.WriteLine("输出4:" + byt1.Count());
            byt2 = byt1.OrderBy(s => s[1]).ToList();
            Console.WriteLine("输出字节:{0}-{1}-{2}", byt2[0][0],byt2[0][1],byt2[0][2]);
            zijie = byt2[0][0];
            Console.WriteLine("输出5:" + zijie);
            by4[0,1] = 0x11;
            Console.WriteLine(by4[0, 1].ToString());
            Console.WriteLine(byt2.ToArray()[0][0].ToString());
            foreach(byte[] item in byt2)
            {
              var  listdata = item.ToList();
                   foreach(var item1 in item)
                    Console.Write("--"+item1.ToString());
                Console.Write("--"+listdata.Count().ToString());
            }

                
            Console.ReadKey();

        }
    }
}
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2019-10-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 CSharp编程大全 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档