Search Forum
(53671 Postings)
Search Site/Articles

Archived Articles
712 Articles

C# Books
C# Consultants
What Is C#?
Download Compiler
Code Archive
Archived Articles
Advertise
Contribute
C# Jobs
Beginners Tutorial
C# Contractors
C# Consulting
Links
C# Manual
Contact Us
Legal

GoDiagram for .NET from Northwoods Software www.nwoods.com


 
Printable Version

Working with Arrays in C#


Open your favorite text editor and type the following C# source code:


using System;

public class ArrayMembers
{
     public static void Main(string[] args)
     {
       //Skip 1 line
          Console.WriteLine("\n");
	      
	            //Iterate through the items of array args using  foreach
		            foreach(string s in args)
			      { 
			               Console.WriteLine(s);
          }

	      //Skip 2 lines
	            Console.WriteLine("\n\n");

		            //Declare array strNames
			      string[] strNames = {"Joe","Mary","Bill","Fred"};

			          //Iterate through the items of array strNames
          for(int i = 0;i < strNames.Length;i++)
	      {
	                 Console.WriteLine("strNames[{0}] = {1}",i,strNames[i]);
          }
     }
}