C# 泛型 泛型与非泛型集合

一、为什么使用泛型编程?

参考C#泛型编程
我们在编写程序时,经常遇到两个模块的功能非常相似,只是一个是处理int数据,另一个是处理string数据,或者其他自定义的数据类型,但我们没有办法,只能分别写多个方法处理每个数据类型,因为方法的参数类型不同。有没有一种办法,在方法中传入通用的数据类型,这样不就可以合并代码了吗?泛型的出现就是专门解决这个问题的。

我们现在要求实现一个栈,这个栈只能处理int数据类型:

public class Stack
{
    private int[] m_item;
    public int Pop()
    {
    }

    public void Push(int item)
    {
    }

    public Stack(int i)
    {
        this.m_item = new int[i];
    }
}

上面代码运行的很好,但是,当我们需要一个栈来保存string类型时,该怎么办呢?很多人都会想到把上面的代码复制一份,把int改成string不就行了。当然,这样做本身是没有任何问题的,但一个优秀的程序是不会这样做的,因为他想到若以后再需要long、Node类型的栈该怎样做呢?还要再复制吗?优秀的程序员会想到用一个通用的数据类型object来实现这个栈。但全面地讲,也不是没有缺陷的,主要表现在:

  • 当Stack处理值类型时,会出现装箱、折箱操作,这将在托管堆上分配和回收大量的变量,若数据量大,则性能损失非常严重。
  • 在处理引用类型时,虽然没有装箱和折箱操作,但将用到数据类型的强制转换操作,增加处理器的负担。

下面是用泛型来重写上面的栈,用一个通用的数据类型T来作为一个占位符,等待在实例化时用一个实际的类型来代替。让我们来看看泛型的威力:

public class Stack<T>
{
    private T[] m_item;
    public T Pop()
    {
    }

    public void Push(T item)
    {
    }

    public Stack(int i)
    {
        this.m_item = new T[i];
    }
}

使用方式

        Stack<int> a = new Stack<int>(100);
        a.Push(10);
        int x = a.Pop();

        Stack<string> b = new Stack<string>(100);
        //这一行编译不通过,因为b只接收string类型的数据
        b.Push(10);
        b.Push("888");
        string y = b.Pop();

这个类和object实现的类有截然不同的区别:

  • 他是类型安全的。实例化了int类型的栈,就不能处理string类型的数据,其他数据类型也一样。
  • 无需装箱和折箱。这个类在实例化时,按照所传入的数据类型生成本地代码,本地代码数据类型已确定,所以无需装箱和折箱。
  • 无需类型转换。
二、Unity3D中常见的泛型

参考在Unity3D中使用泛型(上)
首先,使用泛型机制最明显的是一些集合类。例如在System.Collections.Generic和System.Collections.ObjectModel命名空间中提供了很多泛型集合类。

using System;
using System.Collections.Generic;
using UnityEngine;

public class Example:MonoBehaviour
{
   private void Start()
  {
      //创建一个元素类型为string的List
      List<string> animals=new List<string>();
      //向animals添加string类型的对象
      animals.Add("cats");
      animals.Add("dogs");
      //向animals添加int类型的对象,报错
      animals.Add(1);
   }
}

C#还提供了很多泛型接口。而插入集合中的元素则可以通过实现接口来执行例如排序、查找等操作。例如List<T> 就实现了IList<T>泛型接口,常用的泛型接口也往往定义在System.Collections.Generic中。

除此之外,System.Array类提供了很多静态泛型的方法,例如AsReadOnly、BinarySearch、ConvertAll、Exists、Find、FindAll等。

using System;
using System.Collections.Generic;
using UnityEngine;

public class Example : MonoBehaviour
{
   private void Start()
   {
      Byte[] bytes=new Byte[]{2,1,5,4,3};
      //使用Array类的静态泛型方法sort对Byte排序
      Array.Sort<Byte>(bytes);
      //使用Array类的静态泛型方法BinarySearch查找Byte数组实例bytes中元素1的位置
      int targetIndex=Array.BinarySearch<Byte>(bytes,1);
      Debug.Log(targetIndex);

   }
}
三、泛型方法

参考unity中泛型的全部使用方法

对于泛型方法来说,泛型的作用就是占位和约束的作用。

1.例一
    /// <summary>
    /// 比较等级;
    /// </summary>
    /// <returns>
    /// 若t1>=t2的等级,则返回true;否则返回false
    /// </returns>
    /// where T : IRole where K : IRole的作用是约束传入的两个参数类型必须要实现IRole这个接口;
    /// 这样就定义好了一个泛型方法
    public bool CompareLevel<T,K>(T t1,    K t2) where T : IRole where K : IRole
    {
        //因为泛型t1,t2都被约束需要实现接口,所以我们可以强制转换到IRole来获取level比较
        return ((IRole)t1).level >= ((IRole)t2).level;
    }
    //那么怎么使用呢?
    //接下来看:
    public void Test()
    {
        //先定义三个测试用的类型
        MyNPC npc =new MyNPC();
        MyPlayer player =new MyPlayer();
        MyMonster monster =new MyMonster();
        //对各个类型的level赋值
        npc.level =1;
        player.level =2;
        monster.level =3;
        //比较npc和player的level就很简单了,只需要这样调用即可
        bool b1 = CompareLevel<MyNPC,MyPlayer>(npc,player); //npc?payer//false                    
        bool b2 = CompareLevel<MyNPC,MyMonster>(npc,monster);//npc?monster//false
        bool b3 = CompareLevel<MyPlayer,MyMonster>(player,monster);//payer?monster//false
    }
    
    public interface IRole 
    {
        int level{get;set;}
    }
    public class MyPlayer:IRole
    {
        public int level{get;set;}
    }
    public class MyNPC:IRole
    {
        public int level{get;set;}
    }
    public class MyMonster:IRole
    {
        public int level{get;set;}
    }

where后面的xxxx就是约束,那约束都可以是什么呢?


image.png
2.例二

自动 检测传入的游戏物体是否带有我们想要的组件 如果有 直接返回组件 如果没有 添加之后再返回

    public T GetAndAddComponent<T>(GameObject obj) where T : Component
    {
        if (!obj.GetComponent<T>())//检查该游戏物体是否还有T组件
        {
            obj.AddComponent<T>();//没有添加
        }
        return obj.GetComponent<T>();//本身就有或者是添加之后的返回
    }
四、泛型类

参考unity中泛型的全部使用方法

1.例一
public class fanxing : MonoBehaviour
{
    // Use this for initialization  
    void Start()
    {
        Water<string> test1 = new Water<string>();
        test1.info = "KuangQuanShui";//在此传入水的名字是"矿泉水"(可以将"T"看作是string类型)  
        

        Water<int> test2 = new Water<int>();
        test2.info = 100;//在此传入水的温度是 100(可以将"T"看作是int类型)  
        Debug.Log("水的名字: " + test1.info + "   水的温度: " + test2.info);
    }
}
public class Water<T>
{
    public T info;//水的信息(属性)  
}
2.例二
public class fanxing2 : MonoBehaviour
{
    // Use this for initialization  
    void Start()
    {
        //从A产线出来的生产日期是string类型的"20130610",水是矿泉水,温度是20,  
        //Water<任意类型,直接收WaterBase类型> 在此"T"相当于string类型  
        Water<string, WaterBase> test1 = new Water<string, WaterBase>();
        test1.data = "20130610";
        test1.info.name = "KuangQuanShui";
        test1.info.temperature = 20;
        //从B产线出来的生产日期是int类型的20130610,水是纯净水,温度是20,  
        //Water<任意类型,直接收WaterBase类型> 在此"T"相当于int类型  
        Water<int, WaterBase> test2 = new Water<int, WaterBase>();
        test2.data = 20130610;
        test2.info.name = "ChunJingShui";
        test2.info.temperature = 20;
    }
}
public class Water<T, U> where U : WaterBase //限定"U"只能接收WaterBase类型  
{
    public T data;//出厂日期(可接受int型的20130610,或者string类型的"20130610");  
    public U info;//水的具体信息(矿泉水/纯净水...温度)  
}
public class WaterBase
{
    public string name;
    public int temperature;
}
3. 例三 泛型类的继承
public class fanxing : MonoBehaviour
{
    // Use this for initialization  
    void Start()
    {
        TestChild1 test = new TestChild1();
        test.data = "KuangQuanShui";

        Testchild2 test2 = new Testchild2();
        test2.data = 100;

        Son1 son1 = new Son1();
        son1.data1 = "KuangQuanShui";
        son1.data2 = 10;
    }
}
#region 一个占位符  
public class Test<T>
{
    public T data;
}
public class TestChild1 : Test<string> { }
public class Testchild2 : Test<int> { }
#endregion
#region 两个占位符  
public class Fater<T, U>
{
    public T data1;
    public U data2;
}
public class Son1 : Fater<string, int> { }
#endregion
五、泛型接口
1.例一
interface ITClass<T>
{
    void test(T param);
}

class TClass<T> : ITClass<T>
{
    public void test(T param)
    {
        Debug.Log("test" + param);
    }
}

...
        var b = new TClass<string>();
        b.test("222");
六、泛型与非泛型集合

参考
[C#]泛型与非泛型集合类的区别及使用例程,包括ArrayList,Hashtable,List<T>,Dictionary<Tkey,Tvalue>,SortedList<Tkey,Tvalue>,Queue<T>,Stack<T>等

非泛型集合类 泛型集合类 描述
ArrayList List<T> 表示具有动态大小的对象数组
Hashtable Dictionary<Tkey,Tvalue> 由键值对组成的集合
SortedList SortedList<Tkey,Tvalue> 和字典相似但有排序功能的集合
Queue Queue<T> 表示标准的先进先出(FIFO)队列
Stack Stack<T> 后进先出(LIFO)队列,提供压入和弹出功能

泛型与非泛型集合类在概念和功能上各有不同,其中非泛型集合类在取出值时需要进行类型的转换操作,如果加入值类型会引起装箱和拆箱的操作,这会带来巨大的性能额外开销,如果掌握好泛型数组之后可以不再需要用非泛型的数组了,同时带来类型安全的好处并减少在值类型和引用类型之间的装箱和拆箱。

下面做一个例程来演示一下,先做一个学生类:

        public class student
        {
            public int Number { get; set; }
            public string Name { get; set; }
            public bool Sex { get; set; }
            public student(int _number, string _name, bool _sex)
            {
                Number = _number;
                Name = _name;
                Sex = _sex;
            }
            public override string ToString()
            {
                return string.Format("序号:{0},姓名:{1},性别:{2}",
                    Number.ToString(), Name, Sex ? "男" : "女");
            }
        }
1.ArrayList与List<T>示例
        ArrayList arrayStudents = new ArrayList();
        List<student> listStudnets = new List<student>();

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            addData0();
            showExemple0();
        }

        private void addData0()
        {
            arrayStudents.Add(new student(1, "小颗豆一", true));
            arrayStudents.Add(new student(3, "小颗豆二", false));
            arrayStudents.Add(new student(5, "小颗豆三", true));
            arrayStudents.Add(new student(2, "小颗豆四", false));
            arrayStudents.Add(new student(4, "小颗豆五", true));
            arrayStudents.Add(new student(6, "小颗豆六", false));
            arrayStudents.Add("这里冒一个字符串,需要转换,如果这里是值类型还要进行装箱与拆箱,带来额外的开销!");

            listStudnets.Add(new student(1, "小颗豆一", true));
            listStudnets.Add(new student(3, "小颗豆二", false));
            listStudnets.Add(new student(5, "小颗豆三", true));
            listStudnets.Add(new student(2, "小颗豆四", false));
            listStudnets.Add(new student(4, "小颗豆五", true));
            listStudnets.Add(new student(6, "小颗豆六", false));
        }

        private void showExemple0()
        {
            richTextBox1.AppendText("--------ArrayList与List<T>示例--------\r\n");
            richTextBox1.AppendText("--------非泛型数组的操作(需要强制转换)--------\r\n");
            foreach (var item in arrayStudents)
            {
                if (item is student)
                    richTextBox1.AppendText(item.ToString() + "\r\n");
                else
                    richTextBox1.AppendText((string)item + "\r\n");
            }
            richTextBox1.AppendText("--------泛型数组的操作(不需要强制转换)--------\r\n");
            foreach (var item in listStudnets)
            {
                richTextBox1.AppendText(item.ToString() + "\r\n");
            }
        }

注意观察代码中ArrayList接收的值包括类和字符串,所以要有不同的强制转换,虽然正常运行,但这样带来了安全隐患,泛型集合不需要转换可以轻松调用学生类中自定义的.ToString()


image.png
2.Hashtable与Dictionary<Tkey,Tvalue>示例
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            richTextBox1.Document.Blocks.Clear();
            addData1();
            showExemple1();
        }

        Hashtable hashSudents = new Hashtable();
        Dictionary<string ,student> DictStudents = new Dictionary<string ,student>();

        private void addData1()
        {
            hashSudents.Add("序号1", new student(1, "小颗豆一", true));
            hashSudents.Add("序号2", new student(3, "小颗豆二", false));
            hashSudents.Add("序号3", new student(5, "小颗豆三", true));
            hashSudents.Add("序号4", new student(2, "小颗豆四", false));
            hashSudents.Add("序号5", new student(4, "小颗豆五", true));
            hashSudents.Add("序号6", new student(6, "小颗豆六", false));

            DictStudents.Add("序号1", new student(1, "小颗豆一", true));
            DictStudents.Add("序号2", new student(3, "小颗豆二", false));
            DictStudents.Add("序号3", new student(5, "小颗豆三", true));
            DictStudents.Add("序号4", new student(2, "小颗豆四", false));
            DictStudents.Add("序号5", new student(4, "小颗豆五", true));
            DictStudents.Add("序号6", new student(6, "小颗豆六", false));
        }
        private void showExemple1()
        {
            richTextBox1.AppendText("--------Hashtable与Dictionary<Tkey,Tvalue>示例--------\r\n");
            richTextBox1.AppendText("--------非泛型数组的操作(需要强制转换),注意顺序是特定的------\r\n");
            foreach (DictionaryEntry item in hashSudents)
            {
                richTextBox1.AppendText(item.Key.ToString() + ((student)item.Value).ToString() + "\r\n");
            }
            richTextBox1.AppendText("包含序号2=" + hashSudents.ContainsKey("序号2").ToString() + "\r\n");
            richTextBox1.AppendText("包含序号9=" + hashSudents.ContainsKey("序号9").ToString() + "\r\n");

            richTextBox1.AppendText("--------泛型数组的操作(不需要强制转换),顺序是原来的顺序-----\r\n");
            foreach (KeyValuePair<string, student> item in DictStudents)
            {
                richTextBox1.AppendText(item.Key.ToString() + item.Value.ToString() + "\r\n");
            }
            richTextBox1.AppendText("包含序号2=" + DictStudents.ContainsKey("序号2").ToString() + "\r\n");
            richTextBox1.AppendText("包含序号9=" + DictStudents.ContainsKey("序号9").ToString() + "\r\n");
        }
  • 1)Hashtable不仅需要强制转换,由于它内部的特殊性,所得到的结果跟原序中的结果顺序是不一致的,在需要排序的时候会很麻烦,但Dictionary<Tkey,Tvalue>不仅不需要强制转换,而且顺序跟原序是一致的。
  • 2)Hashtable和Dictionary<Tkey,Tvalue>都仍具有.ContainsKey("序号2");(检查是否包含某键值的项)的方法效率很高。
image.png
3.SortedList与SortedList<Tkey,Tvalue>示例

System.Collections.SortedList类表示键/值对的集合,这些键值对按键排序并可按照键和索引访问。SortedList 在内部维护两个数组以存储列表中的元素;即,一个数组用于键,另一个数组用于相关联的值。

        SortedList sortListStudents = new SortedList();
        SortedList<int, student> sortStudents = new SortedList<int, student>();

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            richTextBox1.Document.Blocks.Clear();
            addData2();
            showExemple2();
        }
       private void addData2()
        {
            sortListStudents.Add(50, new student(1, "小颗豆一", true));
            sortListStudents.Add(20, new student(3, "小颗豆二", false));
            sortListStudents.Add(80, new student(5, "小颗豆三", true));
            sortListStudents.Add(65, new student(2, "小颗豆四", false));
            sortListStudents.Add(44, new student(4, "小颗豆五", true));
            sortListStudents.Add(99, new student(6, "小颗豆六", false));

            sortStudents.Add(50, new student(1, "小颗豆一", true));
            sortStudents.Add(20, new student(3, "小颗豆二", false));
            sortStudents.Add(80, new student(5, "小颗豆三", true));
            sortStudents.Add(65, new student(2, "小颗豆四", false));
            sortStudents.Add(44, new student(4, "小颗豆五", true));
            sortStudents.Add(99, new student(6, "小颗豆六", false));
        }
        private void showExemple2()
        {
            richTextBox1.AppendText("--------SortedList与SortedList<Tkey,Tvalue>示例--------\r\n");
            richTextBox1.AppendText("--------非泛型数组的操作(需要强制转换)---------\r\n");
            foreach (DictionaryEntry  item in sortListStudents )
            {
                richTextBox1.AppendText(item.Key.ToString() + ((student)item.Value).ToString() + "\r\n");
            }
            richTextBox1.AppendText("--------泛型数组的操作(不需要强制转换)--------\r\n");
            foreach (KeyValuePair <int,student > item in sortStudents )
            {
                richTextBox1.AppendText(item.Key.ToString() + item.Value.ToString() + "\r\n");
            }
        }

在这个例程中,两个集合类工作都很好的实现了排序功能,差别仍是一个有强制转换,一个不需要。运行效果如图:


image.png
4.Queue与Queue<T>示例(先进先出)

        Queue queueStuds = new Queue();
        Queue <student > queueStudents=new Queue<student> ();//先进先出
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            richTextBox1.Document.Blocks.Clear();
            addData3();
            showExemple3();
        }

        private void addData3()
        {
            queueStuds.Enqueue(new student(1, "小颗豆一", true));
            queueStuds.Enqueue(new student(3, "小颗豆二", false));
            queueStuds.Enqueue(new student(5, "小颗豆三", true));
            queueStuds.Enqueue(new student(2, "小颗豆四", false));
            queueStuds.Enqueue(new student(4, "小颗豆五", true));
            queueStuds.Enqueue(new student(6, "小颗豆六", false));

            queueStudents.Enqueue(new student(1, "小颗豆一", true));
            queueStudents.Enqueue(new student(3, "小颗豆二", false));
            queueStudents.Enqueue(new student(5, "小颗豆三", true));
            queueStudents.Enqueue(new student(2, "小颗豆四", false));
            queueStudents.Enqueue(new student(4, "小颗豆五", true));
            queueStudents.Enqueue(new student(6, "小颗豆六", false));
        }
        private void showExemple3()
        {
            richTextBox1.AppendText("--------Queue与Queue<T>示例(先进先出)--------\r\n");
            richTextBox1.AppendText("--------非泛型数组的操作(需要强制转换)---------\r\n");
            while (queueStuds .Count >0)
            {
                richTextBox1.AppendText(((student)queueStuds.Dequeue()).ToString() + "\r\n");
            }
            richTextBox1.AppendText("现在数组个数="+queueStuds.Count.ToString() + "\r\n");


            richTextBox1.AppendText("--------泛型数组的操作(不需要强制转换)(先进先出)---------\r\n");
            while (queueStudents.Count > 0)
            {
                richTextBox1.AppendText(queueStudents.Dequeue().ToString() + "\r\n");
            }
            richTextBox1.AppendText("现在数组个数=" + queueStudents.Count.ToString() + "\r\n");
        }

Queue与Queue<T>都使用Enqueue()方法将一个对象加入到队列中,按照先进先出的法则,入栈后使用Dequeue()方法出队。出队后该成员被移除,区别仍是强制转换的问题。运行效果如图:


image.png
5.Stack与Stack<T>示例(先进后出,注意显示数据的顺序)

        Stack stackStudnets1 = new Stack();
        Stack<student> stackStudents2 = new Stack<student>();
        private void button4_Click(object sender, RoutedEventArgs e)
        {
            richTextBox1.Document.Blocks.Clear();
            addData4();
            showExemple4();
        }
        private void addData4()
        {
            stackStudnets1.Push(new student(1, "小颗豆一", true));
            stackStudnets1.Push(new student(3, "小颗豆二", false));
            stackStudnets1.Push(new student(5, "小颗豆三", true));
            stackStudnets1.Push(new student(2, "小颗豆四", false));
            stackStudnets1.Push(new student(4, "小颗豆五", true));
            stackStudnets1.Push(new student(6, "小颗豆六", false));

            stackStudents2.Push(new student(1, "小颗豆一", true));
            stackStudents2.Push(new student(3, "小颗豆二", false));
            stackStudents2.Push(new student(5, "小颗豆三", true));
            stackStudents2.Push(new student(2, "小颗豆四", false));
            stackStudents2.Push(new student(4, "小颗豆五", true));
            stackStudents2.Push(new student(6, "小颗豆六", false));
        }
        private void showExemple4()
        {
            richTextBox1.AppendText("--------Stack与Stack<T>示例(先进后出,注意显示数据的顺序)--------\r\n");
            richTextBox1.AppendText("--------非泛型数组的操作(需要强制转换)---------\r\n");
            for (int i = 0; i < stackStudnets1 .Count ; i++)
            {
                  richTextBox1.AppendText(((student)stackStudnets1.Peek ()).ToString() + "\r\n");              
            }
            richTextBox1.AppendText("(Stack.Peek()是返回不移除)现在数组个数=" + stackStudnets1.Count.ToString() + "\r\n");
            richTextBox1.AppendText("注意:以上数据次次返回的都是最后一次加到数组中的数----------" + "\r\n");
            richTextBox1.AppendText("下边:看看用Stack.Pop()返回并移除的结果:" + "\r\n");
            while (stackStudnets1.Count > 0)
            {
                richTextBox1.AppendText(((student)stackStudnets1.Pop()).ToString() + "\r\n");
            }
            richTextBox1.AppendText("(Stack..Pop()是返回并移除)现在数组个数=" + stackStudnets1.Count.ToString() + "\r\n");

            richTextBox1.AppendText("--------泛型数组的操作(不需要强制转换)---------\r\n");
            while (stackStudents2.Count > 0)
            {
                richTextBox1 .AppendText ((stackStudents2 .Pop ().ToString ()+"\r\n"));
            }
            richTextBox1.AppendText("(Stack.Pop()是返回并移除)现在数组个数=" + stackStudents2.Count.ToString() + "\r\n");

        }

这个集合类,本人感觉用在撤销操作是最方便不过的了,专门记录用户的操作,当需要撤销时,后进的是先出,对象所在位置都不需要判断,如果是泛型直接用即可,如果是非泛型转换一下。

注意,第一部分全是最后一次加入的成员,因为用的是Peek ()方法:返回不移除成员,永远返回最后一个加入的成员;如果用.Pop()方法就不同了:返回并移除,显示的效果及顺序如下图:

image.png

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,088评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,715评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,361评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,099评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 60,987评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,063评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,486评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,175评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,440评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,518评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,305评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,190评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,550评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,880评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,152评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,451评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,637评论 2 335

推荐阅读更多精彩内容

  • C#集合 有两种主要的集合类型:泛型集合和非泛型集合。 泛型集合被添加在 .NET Framework 2.0 中...
    OctOcean阅读 810评论 0 3
  • 数据结构 数据结构是计算机存储、组织、管理数据的方式 数据结构是指相互之间存在一种或多种特定关系的数据元素的集合 ...
    JunChow520阅读 3,571评论 0 4
  • 一、常用集合类型及概念 1.基本关系 许多泛型集合类型均为非泛型类型的直接模拟。 Dictionary< TKey...
    aslbutton阅读 1,407评论 0 49
  • C#集合相关知识 C#里面Collection下面ArrayList 1、动态数组 Array List:动态数组...
    学习中的小白阅读 180评论 0 0
  • 一、数组数组是一组使用数字索引的对象,这些对象属于同一种类型。虽然C#为创建数组提供了直接的语言支持,但通用类型系...
    CarlDonitz阅读 648评论 0 1