The following Program is a Example of getting 10 integer numbers (from -1000 to 1000) from User and Store it in an array and sort them and Display. .
WITH .NET Feature :
WITH .NET Feature :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
String num_str;
int[] num = new int[10];
int temp;
bool num_flag = false;
Console.WriteLine("Enter 10 integer number:");
for(int i = 0 ; i < 10 ; i++)
{
Console.WriteLine("enter {0} number",i);
num_str = Console.ReadLine();
num_flag = int.TryParse(num_str, out temp);
while (num_flag == false)
{
Console.WriteLine("please Enter interger");
num_str = Console.ReadLine();
num_flag = int.TryParse(num_str, out temp);
}
if ((temp >= -1000) && (temp <= 1000))
{
num[i] = temp;
}
else
{
Console.WriteLine("Please Enter number (-1000 <= x <= 1000");
i--;
}
}
Array.Sort(num);
foreach (int value in num)
{
Console.Write(value);
Console.Write(' ');
}
Console.ReadLine();
}
}
}
WITHOUT .NET Feature :
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
String num_str;
int[] num = new int[10];
int temp;
bool num_flag = false;
Console.WriteLine("Enter 10 integer number:");
for(int i = 0 ; i < 10 ; i++)
{
Console.WriteLine("enter {0} number",i);
num_str = Console.ReadLine();
num_flag = int.TryParse(num_str, out temp);
while (num_flag == false)
{
Console.WriteLine("please Enter interger");
num_str = Console.ReadLine();
num_flag = int.TryParse(num_str, out temp);
}
if ((temp >= -1000) && (temp <= 1000))
{
num[i] = temp;
}
else
{
Console.WriteLine("Please Enter number (-1000 <= x <= 1000");
i--;
}
}
Array.Sort(num);
foreach (int value in num)
{
Console.Write(value);
Console.Write(' ');
}
Console.ReadLine();
}
}
}
WITHOUT .NET Feature :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
String num_str;
int[] num = new int[10];
int temp;
bool num_flag = false;
Console.WriteLine("Enter 10 integer number:");
for(int i = 0 ; i < 10 ; i++)
{
Console.WriteLine("enter {0} number",i);
num_str = Console.ReadLine();
num_flag = int.TryParse(num_str, out temp);
while (num_flag == false)
{
Console.WriteLine("please Enter interger");
num_str = Console.ReadLine();
num_flag = int.TryParse(num_str, out temp);
}
if ((temp >= -1000) && (temp <= 1000))
{
num[i] = temp;
}
else
{
Console.WriteLine("Please Enter number (-1000 <= x <= 1000");
i--;
}
}
//Array.Sort(num);
for (int x = 0; x < num.Length; x++)
{
for (int y = 0; y < num.Length - 1; y++)
{
if (num[y] > num[y + 1])
{
int temp1 = num[y + 1];
num[y + 1] = num[y];
num[y] = temp1;
}
}
}
foreach (int value in num)
{
Console.Write(value);
Console.Write(' ');
}
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
String num_str;
int[] num = new int[10];
int temp;
bool num_flag = false;
Console.WriteLine("Enter 10 integer number:");
for(int i = 0 ; i < 10 ; i++)
{
Console.WriteLine("enter {0} number",i);
num_str = Console.ReadLine();
num_flag = int.TryParse(num_str, out temp);
while (num_flag == false)
{
Console.WriteLine("please Enter interger");
num_str = Console.ReadLine();
num_flag = int.TryParse(num_str, out temp);
}
if ((temp >= -1000) && (temp <= 1000))
{
num[i] = temp;
}
else
{
Console.WriteLine("Please Enter number (-1000 <= x <= 1000");
i--;
}
}
//Array.Sort(num);
for (int x = 0; x < num.Length; x++)
{
for (int y = 0; y < num.Length - 1; y++)
{
if (num[y] > num[y + 1])
{
int temp1 = num[y + 1];
num[y + 1] = num[y];
num[y] = temp1;
}
}
}
foreach (int value in num)
{
Console.Write(value);
Console.Write(' ');
}
Console.ReadLine();
}
}
}



D4EE27FFC5
ReplyDeleteTakipçi Satın Al
Footer Link Satın Al
Google Yorum Satın Al
Dragon City Elmas Kodu
Titan War Hediye Kodu
The article provides a useful example of sorting integer values in C#, covering both the built-in .NET approach and a manual sorting implementation. It is a good introductory example for understanding arrays, input validation, loops, and how sorting logic can be applied in a simple console application.
DeleteFor developers learning C# in a broader application-development context, examples like this also help connect basic programming concepts with practical backend development. Exploring ASP.NET Core Angular Full Stack Developer Training can provide a wider perspective on how .NET technologies are used alongside modern web application development.
The comparison between Array.Sort() and manually implementing the sorting process is particularly useful for understanding what framework features provide behind the scenes. For learners who want to build stronger .NET development skills and move beyond individual C# exercises, Dot Net Full Stack Developer Training can be a relevant next step.
Delete9E149DE2F1
ReplyDeleteGörüntülü Show
Canlı Cam Show
Whatsapp Ücretli Şov
ReplyDeleteDoğal güzellikleri ve tarihi zenginlikleriyle ünlü olan bölge, ziyaretçilere unutulmaz bir deneyim sunar. Gün batımında gökyüzünün renkleriyle bütünleşen peri bacaları, adeta masalsı bir ortam yaratır. Eğer bu eşsiz atmosferi keşfetmek isterseniz, https://bayanserik.space/ adresini ziyaret edebilirsiniz. Tarih boyunca birçok medeniyete ev sahipliği yapmış bu alan, kültürel mirasıyla da dikkat çeker.
02610C52
ReplyDeleteUrfa
Balıkesir
Siirt
Muğla
Batman
Çorum
Kütahya
Yozgat
Şırnak
9604CFF7
ReplyDeleteGaziemir
Datça
Edremit
Gazipaşa
Pamukova
Soma
Birecik
Çatalca
Oğuzeli
EFB49F5B
ReplyDeleteAkseki
Menemen
İzmit
Sur
Ergani
Ezine
Silifke
İlkadım
Çivril