О динамическом Dictionary - C#

Узнай цену своей работы

Формулировка задачи:

Почему не выводит r1-e1, а выводит {Key=r1 }- { Value=e" } ?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Les
{

    class Program
    {
        static void Main(string[] args)
        {

            var dictionary = new Dictionary<dynamic, dynamic> {
 
                {new {Key="r1" },new { Value="e1" } },
                {new {Key="r2" },new { Value="e2" } },
                {new {Key="r3" },new { Value="e3" } },
                {new {Key="r4" },new { Value="e4" } },
                {new {Key="r5" },new { Value="e5" } },
                {new {Key="r6" },new { Value="e6" } },
                {new {Key="r7" },new { Value="e7" } },
                {new {Key="r8" },new { Value="e8" } },
                {new {Key="r9" },new { Value="e9" } },
                {new {Key="r10" },new { Value="e10" } }
            };

            foreach (var i in dictionary)
            {
                Console.WriteLine( "{0}-{1}", i.Key,i.Value);
            }

        }
    }
}

Решение задачи: «О динамическом Dictionary»

textual
Листинг программы
            foreach (var i in dictionary)
            {
                Console.WriteLine("{0}-{1}", i.Key.Key, i.Value.Value);
            }

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

8   голосов , оценка 4.25 из 5
Похожие ответы