c# - 如何在控制台中查看列表的内容?
问题描述
我有这个变量:
public static List<Phrase> viewablePhrases;
我想看到控制台中记录的内容是这样的:
Console.WriteLine(App.viewablePhrases)
但这并没有向我显示内容。
有没有办法可以在我的控制台中查看内容?
解决方案
您正在尝试显示列表,而不是您添加到列表中的对象的值:
Phrase
您应该输出包含您的对象的字符串值:
public static List<Phrase> viewablePhrases
{
new Phrase(/* your constructor */)
// other your Phrase objects
};
for(int i = 0; i < viewablePhrases.Count; i++)
{
Console.WriteLine(viewablePhrases[i].Value); // or other property instad of "Value"
}
推荐阅读
- python - Flatlib 使用当前日期和时间
- android - MultiUserChatException$NotAMucServiceException: Can not join ... ,因为 'localhost' 不提供 MUC (XEP-45) 服务
- jquery - 在页面加载时,下拉列表的选定值(动态出现)在警报或控制台中显示未定义
- reactjs - 在 Meteorjs 中显示最新创建的用户和角色时的 Pub-Sub 问题
- mysql - 想要更新数据库中输入的条目。我有代码并显示错误:
- r - R在打开netcdf文件时崩溃
- rest-assured - 放心:- 从使用 Pathparam 和 FormParam 创建的 Post 请求中获得 404 响应
- json - 使用nodejs获取带有标头的json
- javascript - 散点图缩放在 d3.js 中无法正常工作
- html - 如何将父 div 的高度设置为具有位置的子 div:绝对