c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

How to create and sort array in asp.net c#?

| | ASP-NET , CSharp

In c# arrays are declared using square braces and it provides members for working with its contained data. The following code declares an array with some initial data and then sorts the array.

           try
           {
                //declare and initialize the array
                int[] arr = { 53, 2, 10, 22 };
                Array.Sort(arr);
               Console.WriteLine("{0},{1},{2},{3}", arr[0], arr[1], arr[2], arr[3]);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
 

Output:

22,10,22,53