using System;
class Program
{
static void Main()
{
// A
// Basic array length example.
int[] arrayA = new int[5];
int lengthA = arrayA.Length;
Console.WriteLine(lengthA); // Writes 5
// B
// Long array length example.
long longLength = arrayA.LongLength;
Console.WriteLine(longLength); // Writes 5
// C
// Zero length array example.
int[] zero = new int[0];
int lengthZero = zero.Length;
Console.WriteLine(lengthZero); // Writes 0
// D
// Null array length example exception.
// int[] dead = null;
// Console.WriteLine(dead.Length);
// E
// GetLength 0 example.
int lengthE = arrayA.GetLength(0);
Console.WriteLine(lengthE); // Writes 5
// F
// GetLength 1 example exception.
// int lengthF = arrayA.GetLength(1);
// Console.WriteLine(lengthF);
// G
// Two-dimensional GetLength example.
int[,] two = new int[5, 10];
Console.WriteLine(two.GetLength(0)); // Writes 5
Console.WriteLine(two.GetLength(1)); // Writes 10
// H
// Two-dimensional Length example.
Console.WriteLine(two.Length); // Writes 50
}
}
Date :
2009-05-19 15:12:22
By :
Gg
No. 3
Guest
Code (C#)
// initialize an array of integer type
int[] a = { 1, 5, 10, 15, 20 };
// foreach (type variable in expression)
foreach (int b in a)
{
Response.Write(b + "<br />");
}
Date :
2011-06-29 10:50:00
By :
สวย
No. 4
Guest
โปรแกรมนี้มีไว้ทำอะไรช่วยบอกทีคับ
Code
// 1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
int main(void)
{
int a[3][4],r,c;
for(r=0; r<=2; r++)
for(c=0;c<=3;c++)
{
printf("Entry Number");
scanf("%d",&a[r][c]);
}
for(r=0; r<=2; r++)
for(c=0;c<=3;c++)
{
printf("\n Display");
printf("%d",a[r][c]);
}
scanf("%d",&a);
return 0;
}