相关疑难解决方法(0)

这是在C#中迭代Concurrentdictionary的正确方法吗?

我只是用这个代码作为例子.假设我有以下Person类.

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

namespace dictionaryDisplay
{
class Person
{
    public string FirstName { get; private set;}
    public string LastName { get; private set; }

    public Person(string firstName, string lastName)
    {
        this.FirstName = firstName;
        this.LastName = lastName;

    }

    public override string ToString()
    {
        return this.FirstName + " " + this.LastName;
    }
}
Run Code Online (Sandbox Code Playgroud)

}

主要计划

static void Main(string[] args)
    {
        ConcurrentDictionary<int, Person> personColl = new ConcurrentDictionary<int,   Person>();

        personColl.TryAdd(0, new Person("Dave","Howells"));
        personColl.TryAdd(1, new Person("Jastinder","Toor"));

        Person outPerson = …
Run Code Online (Sandbox Code Playgroud)

c# concurrent-programming

30
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

concurrent-programming ×1