skip to main | skip to sidebar

OPEN SOURCE

Linux for Better life

  • Home
  • Trik-Tips
  • Free Template
  • Blogger Hack
  • Free Ebook

C Sharp

ARRAY

using System;

namespace Arrays
{
class Arrays
{
public static void PrintArray(int[] myInts)
{
for(int i = 0; i <>

public static string[] GetStringArray()
{
string[] theStrings = {"Hello", "from", "GetStringArray"};
return theStrings;
}

public static int Main(string[] args)
{
#region Array declarations

// A string array containing 10 elements {0, 1, ...,9}.
string[] booksOnCOM;
booksOnCOM = new string[10];

// A 2 item string array, numbered {0, 1}
string[] booksOnPL1 = new string[2];

// 100 item string array, numbered {0, 1, ..., 99}
string[] booksOnDotNet = new string[100];

// The size of this array will automatically be set to 4.
// Note the lack of the 'new' keyword.
int[] ages = {20, 22, 23, 0};

// Need 'new' keyword when you define a fixed size array.
// Uncomment to trigger error.
// int[4] ages = {30, 54, 4, 10}; // Error!
#endregion

Console.WriteLine("***** Array as Parameter *****");
PrintArray(ages);

Console.WriteLine("\n***** Array as return value *****");
string[] strs = GetStringArray();
foreach(string s in strs)
Console.WriteLine(s);

Console.WriteLine("\n***** A rectangular MD array *****\n");
int[,] myMatrix;
myMatrix = new int[6,6];

// Populate (6 * 6) array.
for(int i = 0; i < j =" 0;">

// Show (6 * 6) array.
for(int i = 0; i < j =" 0;">

Console.WriteLine("\n***** A jagged MD array *****\n");
int[][] myJagArray = new int[5][];

// Create the jagged array.
for (int i = 0; i < i =" 0;" j =" 0;">

// Initialize items at startup or...
Console.WriteLine("\n***** Created array of strings *****");
string[] firstNames =
new string[5]{"Steve", "Gina", "Swallow", "Baldy", "Gunner"};

// ...go member by member.
/*
string[] firstNames = new string[4];
firstNames[0] = "Steve";
firstNames[1] = "Gina";
firstNames[2] = "Swallow";
firstNames[3] = "Baldy";
firstNames[4] = "Gunner";
*/

// Print out names in declared order.
for(int i = 0; i <>

// ... and print them.
Console.WriteLine("\n\n***** Here is the array once reversed *****");
for(int i = 0; i <>

// Clear out all but the final member.
Console.WriteLine("***** Cleared out all but young Gunner *****");
Array.Clear(firstNames, 1, 4);
for(int i = 0; i <>

Posted by MALIK

Labels: c#

0 comments:

Post a Comment

Newer Post Older Post Home

Links

  • ALJAZEERA TV
  • ANTARA
  • Bali`s Blogger
  • BBC
  • BERITANET.COM
  • CHIP ONLINE
  • CNN
  • DETIK.COM
  • E-BOOK
  • Economic
  • Friends
  • Friendster's Blog
  • Habibieafsyah
  • HARVARD UNIVERSITY
  • ILMU KOMPUTER
  • INFO LINUX
  • KICK ANDY
  • LINUX OpenSuse
  • LINUX SLAX
  • Linux Temanggung
  • LINUX UBUNTU
  • LIPUTAN 6 SCTV
  • MASTER BLOGGER
  • METROTV NEWS
  • MUSIC DOWNLOAD
  • My Class
  • Robotic AMIKOM
  • SMA N 3 TEMANGGUNG
  • SMART E-LEARNING
  • SOFTPEDIA
  • STMIK AMIKOM
  • SUPPORTED BLOGGER
  • TIPS TRICKS
  • TRIAL FILM
  • TV ONE ONLINE

Blog Archive

  • ► 2009 (38)
    • ► 05/31 - 06/07 (1)
    • ► 02/15 - 02/22 (1)
    • ► 01/11 - 01/18 (11)
    • ► 01/04 - 01/11 (25)
  • ▼ 2008 (70)
    • ► 11/30 - 12/07 (22)
    • ► 11/16 - 11/23 (18)
    • ► 11/09 - 11/16 (1)
    • ► 10/26 - 11/02 (5)
    • ► 10/19 - 10/26 (16)
    • ▼ 10/12 - 10/19 (4)
      • C Sharp
      • C Sharp
      • C Sharp
      • LINUX
    • ► 10/05 - 10/12 (4)



$100.00 Anda pasti untung setelah registrasi!






Search Engine Optimization and SEO Tools







Bookmark CO.CC:Free Domain