This is simple example to demonstrate the use of array. Please send us email or comment below if you feel any problem while using arrays.
using System;
using System.Text;
using System.Data;
namespace Console_App
{
public class clsArray
{
public static void Main()
{
try
{
int[] iInts = { 15, 20, 25 };
bool[][] bBools = new bool[2][];
bBools[0] = new bool[2];
bBools[1] = new bool[1];
double[,] dDoubles = new double[2, 2];
string[] sStrings = new string[3];
Console.WriteLine("Arrya Example");
Console.WriteLine();
Console.WriteLine("iInts[0]: {0}, iInts[1]: {1}, iInts[2]: {2}", iInts[0], iInts[1], iInts[2]);
bBools[0][0] = false;
bBools[0][1] = false;
bBools[1][0] = true;
Console.WriteLine("bBools[0][0]: {0}, bBools[1][0]: {1}", bBools[0][0], bBools[1][0]);
dDoubles[0, 0] = 2.11;
dDoubles[0, 1] = 1.830;
dDoubles[1, 1] =11.111;
dDoubles[1, 0] = 55.55667788;
Console.WriteLine("dDoubles[0,0]: {0}, dDoubles[1,0]: {1}", dDoubles[0, 0], dDoubles[1, 0]);
sStrings[0] = "Csharptalk.com";
sStrings[1] = "Indihub.com";
sStrings[2] = "bharatclick.com";
Console.WriteLine("sStrings[0]: {0}, sStrings[1]: {1}, sStrings[2] {2}", sStrings[0], sStrings[1], sStrings[2]);
}
catch (Exception ex)
{
//handle exception here
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment