C#打印字符串数组列表 [英] C# Print list of string array

查看:506
本文介绍了C#打印字符串数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#的新手,并且有一个问题,我该如何打印字符串数组列表?我可以使用Console.WriteLine从string []进行操作,但是如果我使用forEach进行列表操作,它只会打印出System.String [],在为每个方法使用索引时如何写索引?

I'm very new to c# and have a question, how do I print list of string arrays? I can do it from string[] using Console.WriteLine, but if I do that for list with forEach it just prints out System.String[], how do I write index when using for each?

推荐答案

最简单的方法是这样的: 使用 String.Join

Simplest way is this: using String.Join

string[] arr = new string[] { "one", "two", "three", "four" };
Console.WriteLine(String.Join("\n", sarr)); 

希望这会有所帮助.

这篇关于C#打印字符串数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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