Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5.  
  6. namespace ConsoleApp1
  7. {
  8.     class Program
  9.     {
  10.         internal class Data
  11.         {
  12.             private int P1 { get; set; }
  13.             private string X { get; set; }
  14.             private byte Something { get; set; }
  15.             // ...
  16.             private double P10 { get; set; }
  17.         }
  18.  
  19.         static void Main()
  20.         {
  21.             IDictionary<int, Data> dic = new Dictionary<int, Data>();
  22.             for (var i = 1; i <= 300_00; i++)
  23.             {
  24.                 dic.Add(i, new Data());
  25.             }
  26.  
  27.             var tp = dic.GetType().GetGenericArguments()[1].GetProperties((BindingFlags.NonPublic | BindingFlags.Instance));
  28.             List<PropertyInfo> lProperties = new List<PropertyInfo>();
  29.             Array.ForEach(tp, (p) =>
  30.             {
  31.                 if (p.Name != "Something")
  32.                 {
  33.                     lProperties.Add(p);
  34.                 }
  35.             });
  36.  
  37.             foreach (var kvp in dic)
  38.             {
  39.                 object[] @out = new object[lProperties.Count];
  40.  
  41.                 foreach (var property in lProperties)
  42.                 {
  43.                     @out[p] = property.GetValue(kvp.Value);
  44.                 }
  45.             }
  46.             Console.WriteLine("Done");
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement