Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- namespace ConsoleApp1
- {
- class Program
- {
- internal class Data
- {
- private int P1 { get; set; }
- private string X { get; set; }
- private byte Something { get; set; }
- // ...
- private double P10 { get; set; }
- }
- static void Main()
- {
- IDictionary<int, Data> dic = new Dictionary<int, Data>();
- for (var i = 1; i <= 300_00; i++)
- {
- dic.Add(i, new Data());
- }
- var tp = dic.GetType().GetGenericArguments()[1].GetProperties((BindingFlags.NonPublic | BindingFlags.Instance));
- List<PropertyInfo> lProperties = new List<PropertyInfo>();
- Array.ForEach(tp, (p) =>
- {
- if (p.Name != "Something")
- {
- lProperties.Add(p);
- }
- });
- foreach (var kvp in dic)
- {
- object[] @out = new object[lProperties.Count];
- foreach (var property in lProperties)
- {
- @out[p] = property.GetValue(kvp.Value);
- }
- }
- Console.WriteLine("Done");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement