I have two hashsets that I want to except to get the distinct data:
var dataA = new HashSet<string>();
var dataB = new HashSet<string>();
var exceptA = dataA.Except(dataB);
var exceptB = dataB.Except(dataA);
var result = exceptA.Union(exceptB);
var container = new HashSet<string>(result);
dgv_B.DataSource = container.ToList();
My problem is when I insert the container into the datageid, this is my result:
And this is the raw data from breakpoints:
How can I display the text in the DGV?
CodePudding user response:
The answer was given by fellow @GoodNightNerdPride:
It seems that the DGV does not work with lists of primitive types. It expects objects and analyzes their properties to generate the columns (a string has a Length property). Try something like this instead:
dgv_B.DataSource = container.Select(s => new { Value = s }).ToList();