C# 配列

書き方

変数   型名 = {};

は配列のインデックスだと思う。

実際の数値は{}

int array = {2,3,4,5,12,42,}

 

個人的にはこの書き方が好き。

配列の個数とか特に考えるきが無いので。

 

            for (int i = 0; i < d.Length; i++)
            {
                Console.Write(d[i] + ", ");
            }

 

これで作った配列分だけループ

            for (int i = 0; i < d.Length; ++i)
            {
                Console.Write(d[i] + ", ");
            }

のほうがいいのかな?

 

ufcpp.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string args)
        {
            int  [] d =  {11,33,33,22,33,55,553,112,444,112,442,1124,553,232};
            for (int i = 0; i < d.Length; i++)
            {
                Console.Write(d[i] + ", ");
            }
            Console.WriteLine("\n\n\n\n");

       

            String test = "Hellow World";

            for (int i = 0; i < test.Length; i++)
            {

                Console.WriteLine(test[i]);
            }
        }
    }
}

こっちもある。

new 書くのめんどくさいw

型名[] 変数名 = new 型名[] {値1, 値2, .....};