我如何打印此列表

时间:2019-06-26 01:01:08

标签: c# linq

我制作了一个字典,并通过Linq将值提取到var列表中。

但是,我在打印此列表时遇到问题。

我不知道该变量列表的内容。

我想把这张清单装满并打印出来。

Console.WriteLine(myList); myList.ToList()。ForEach(Console.WriteLine);

我也尝试了嵌套循环。 buf失败了

输出为“ CADImportNetDemos.CADViewersDemo.MainForm + textDataType”

// made a class for a dictionary
class textDataType
        {
            public string text { get; set; }
            public double textPoint1X { get; set; }
            public double textPoint1Y { get; set; }
        }
// declare a dictionary
var textDataDictionary = new Dictionary<UInt64, textDataType>();
// add a data to dictionary
 textDataDictionary.Add(textData.Handle,
                                      new textDataType
                                      {
                                         text = textData.Text,
                                         textPoint1X = textData.Point1.X,
                                         textPoint1Y = textData.Point1.Y
                                       });

// Query and make var my list
 var myList = textDataDictionary.Values.Where(
                x => x.textPoint1X > 2350 &&
                x.textPoint1X < 2355 &&
                x.textPoint1Y > -300 &&
                x.textPoint1Y < -298).ToList();

如此打印:文本,Point1X,Point1Y

不是“ CADImportNetDemos.CADViewersDemo.MainForm + textDataType”

0 个答案:

没有答案