System.Int32 []数组元素的显示,而不是 [英] System.Int32[] displaying instead of Array elements

查看:166
本文介绍了System.Int32 []数组元素的显示,而不是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示数组元素,但总是得到这个输出 System.Int32 []
而不是整数元素。

 使用System.IO;
使用系统;类测试
{
    公共静态无效的主要()
    {
        INT [] =改编新INT [26];
        的for(int i = 0; I< 26;我++)
        改编[我] =我;        Console.WriteLine(阵行:+ ARR);
    }
}


解决方案

您需要循环的内容,并打印出来 -

  Console.WriteLine(阵行);
的for(int i = 0; I< 26;我++)
{
     改编[我] =我;
     Console.WriteLine(+常用3 [I]);
}

简单的打印改编将调用的ToString()的阵列和打印其类型

I am trying to display array elements but always getting this output System.Int32[] instead of integer elements.

using System.IO;
using System;

class Test
{
    public static void Main()
    {
        int[] arr=new int [26];
        for(int i = 0; i < 26; i++)
        arr[i] = i;

        Console.WriteLine("Array line : "+arr);
    }
}

解决方案

You need to loop over the content and print them -

Console.WriteLine("Array line: ");
for(int i=0;i<26;i++)
{
     arr[i]=i;
     Console.WriteLine(" " + arr[i]);
}

Simply printing arr will call ToString() on array and print its type.

这篇关于System.Int32 []数组元素的显示,而不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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