关于打印列表< T>的问题向屏幕 [英] question about print List<T> to screen

查看:44
本文介绍了关于打印列表< T>的问题向屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个关于List的问题;

A question about List;

当我有"List< PlugwiseMessage> msg" 和图片中的值时:

When i have "List<PlugwiseMessage> msg" with the value's from the picture :

我只得到PlugwiseLib.BLL.BC.PlugwiseMessage作为输出.

I only get PlugwiseLib.BLL.BC.PlugwiseMessage as output.

但是如何在屏幕上查看 _message,_owner和_type 中的值?还是<消息,所有者和类型的值?

But how can i see the value's from _message, _owner and _type on my screen ? or the value's of Message, Owner, and Type?

有人可以向我解释差异吗?

And can somebody explain the difference to me ?

推荐答案

您的列表包含 PlugwiseLib.BLL.BC.PlugwiseMessage 对象的集合.消息,所有者和类型是对象上的属性._message,_owner和_type变量是属性公开的后备字段.

Your list has a collection of PlugwiseLib.BLL.BC.PlugwiseMessage objects. Message, Owner and Type are properties on the object. The _message, _owner and _type variables are the backing fields that are exposed by the properties.

在执行控制台输出时,您正在 PlugwiseMessage 对象上调用 .ToString(). ToString()的默认行为是打印对象的名称.如果要显示属性,则需要添加几行

When you are doing the console output, you are calling .ToString() on the PlugwiseMessage object. The default behavior of ToString() is to print the name of the object. If you want to display the properties you will need to add several lines

Console.WriteLine(msg[i].Message);
Console.WriteLine(msg[i].Owner);
Console.WriteLine(msg[i].Type);

这篇关于关于打印列表&lt; T&gt;的问题向屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆