Home
>
Tutorials For Beginners
>
C Sharp Tutorial - Index
>
Array Ch-1
Tutorials For Beginners
Index - Core Java Tutorial
Ch1-Install Apache
Ch2-Create Project Space
Ch3-Writing The First Code
Ch4-Data Types in Java
Ch5-Arrays in Java
Connecting To DB
WPF Tutorial - Index
Ch1 - Launching WPF
C Sharp Tutorial - Index
Ch1 - First Program
Array Ch-1
Struts Tutorials
PHP Tutorial - Index
Ch3 - First PHP
Quiz
Quiz
Loopholes in Java
Experiences
History of Java
Guestbook
Admin
Seach Results
Deepak Gupta
Deepak Gupta Portal
Arrays can be termed as a collection of similar data types, indexed by the nature. An array can be of type integer,Strings or any data type. The array class is derived from System.Array.* .
C# defines many operations which can be performed on any Array class. An array of String class can be defined as :
String[] arrayToBeSorted = { "Deepak","gupta","knows","Sharp" };
Now I will show how to sort and reverse sort this array string using C#.
Open up a console windows application as shown in First Example , and type the following code :
using System; using System.Collections.Generic; using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public static void SortMyArray(object[] sortArray)
{
foreach (object obj in sortArray)
{
Console.WriteLine("Value: {0}",obj);
}
Console.WriteLine("\n");
}
static void Main(string[] args)
{
String[] arrayToBeSorted =
{ "Deepak","gupta","knows","Sharp" };
SortMyArray(arrayToBeSorted);
Array.Reverse(arrayToBeSorted);
SortMyArray(arrayToBeSorted);
System.Console.ReadLine();
}
}
}
Running this program and check the output.
Looking for Something more ... check the google
Comment
Comment By
Datetime
Drop a Comment
Comment
Name
Mail ID
Phone number