Làm thế nào để khải báo mảng một chiều kiểu số trong CSharp? (How to declare one dimensional number array in CSharp?)


Nếu bạn chưa biết về mảng(Array) hãy tham khảo trước bài viết viết Mảng/Array là gì?. Trong bài viết này tôi sẽ giới thiệu bài tập khai báo mảng số(declare number array) trong C#.






HowToDeclareNumberArray.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Author: developer.bnson@gmail.com
// Website: vnlives.net

namespace HowToDeclareNumberArray
{
    class Program
    {
        static void Main(string[] args)
        {

            double[] arrDou = new double[5];
            int i;

            arrDou[0] = 5.25;
            arrDou[1] = 72.2;
            arrDou[2] = 341.00;
            arrDou[3] = 3.65656565;
            arrDou[4] = 8.99999999;

            for (i = 0; i < 5; i++)
            {
                Console.WriteLine("arrDou[" + i + "]: " + arrDou[i]);
            }
               
            Console.ReadLine();

        }
    }
}

Kết quả - Result:


















No comments:

Post a Comment