"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Wednesday, August 17, 2011

Array in C# Part 2 [ Sort Reverse , IndexOf , LastIndexOf ]

Hi *.*,
Before reading this pls go through part 1(Last post).
 Array Reverse 
 

int[] intArray = new int[] { 4, 1, 3,3, -23,-23,6 };
Array.Reverse(intArray);
Output
Array IndexOf


int[] intArray = new int[] { 4, 1, 3,3, -23,-23,6 };
int idx = Array.IndexOf(intArray, -23);
 Output
 Array LastIndexOf

int[] intArray = new int[] { 4, 1, 3,3, -23,-23,6 };
int lstidx = Array.LastIndexOf(intArray, -23);
Output
 Difference b\w IndexOf and LastIndexOf
 
The method indexOf() returns the first occurrence (index) of a given character or a combination as parameter in a given string.
The method lastIndexOf() returns the last occurrence (last index) of a given character or combination in a given string.
For ur easy understanding i had given same value for both method.

Hope u got all
Take care
Have a nice day... 'N happy Coding :)

No comments: