using System;
namespace text2
{
class Program
{
static void Main(string[] args)
{
//源代码,这里我用的还是java的思路,以为直接传个数组名上去,就能输出整个数组元素。但可惜的是这里是c#的地盘,这个方法行不通。
String[] star={"孟美岐","吴宣仪","杨超越","段奥娟","Yamy","赖美云","张紫宁","杨芸晴","李紫婷","傅菁","徐梦洁"}
Console.WriteLine(star);
//按照着这种方法输出字符串数组就会打印System.String[],输出数字数组就会打印System.Int32[]
//解决方法
//使用foreach循环遍历数组或者使用for循环遍历数组,这里推荐使用foreach,代码量少一点
foreach (string i in star)
{
Console.Write(i + " ");
}
}
}
}
【C#】输出数组名,反而输出System.Int32[]或者System.String[]的解决方法
最新推荐文章于 2023-07-31 13:53:41 发布