مرتب سازی و جستجو در ArrayList با استفاده از متود Sort() و BinarySearch در #C
سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب ، مرتب سازی و جستجو در ArrayList با استفاده از متود Sort() و BinarySearch در سی شارپ #C رو براتون آماده کردم. انشاالله که این کد براتون مفید باشه.
خروجی پروژه به این صورت می باشد:
Original contents: 155 413 -41 818 31 191
Contents after sorting: -41 31 155 191 413 818
Index of 413 is 4
Contents after sorting: -41 31 155 191 413 818
Index of 413 is 4
مرتب سازی و جستجو در ArrayList با استفاده از متود Sort() و BinarySearch :
sing System;
using System.Collections;
class MainClass {
public static void Main() {
// create an array list
ArrayList al = new ArrayList();
// Add elements to the array list
al.Add(155);
al.Add(413);
al.Add(-41);
al.Add(818);
al.Add(31);
al.Add(191);
Console.Write("Original contents: ");
foreach(int i in al)
Console.Write(i + " ");
Console.WriteLine("\n");
// Sort
using System.Collections;
class MainClass {
public static void Main() {
// create an array list
ArrayList al = new ArrayList();
// Add elements to the array list
al.Add(155);
al.Add(413);
al.Add(-41);
al.Add(818);
al.Add(31);
al.Add(191);
Console.Write("Original contents: ");
foreach(int i in al)
Console.Write(i + " ");
Console.WriteLine("\n");
// Sort