C# arrays are zero indexed; that is, the array indexes start at zero. Arrays in C# work similarly to how arrays work in most other popular languages.Here i'm disgussing abt how to implement some function using array in c# and vb.
Array intialize
- Sorting Array (Integer)
- Sorting Array (Alphabet)
- getting duplicate element from array
public void aay()
{
int[] intArray = new int[] { 4, 1, 3,3, -23,-23 }; // Array intialize
Array.Sort(intArray); // Sort Array
string _duplicatelink = string.Empty;
for (int i = 0; i <= intArray.Length; i++) // Function getting duplicate element from array
{
if (intArray[i] == intArray[i + 1])
{
_duplicatelink = _duplicatelink + "," + intArray[i];
}
}
}
public void sortalpha() // Sorting Alphabet
{
String[] strArray = new String[] { "z", "a", "C" };
Array.Sort(strArray);
}
Using VB
Public Sub aay()
Dim intArray As Integer() = New Integer() {4, 1, 3, 3, -23, -23}
' Array intialize
Array.Sort(intArray)
' Sort Array
Dim _duplicatelink As String = String.Empty
For i As Integer = 0 To intArray.Length
' Function getting duplicate element from array
If intArray(i) = intArray(i + 1) Then
_duplicatelink = _duplicatelink & "," & intArray(i)
End If
Next
End Sub
Public Sub sortalpha()
' Sorting Alphabet
Dim strArray As [String]() = New [String]() {"z", "a", "C"}
Array.Sort(strArray)
End Sub
Stay Tune...
Have a nice day... 'N happy Coding :)
No comments:
Post a Comment