سلام بر برنامه نویسان عزیز با یه کد سی شارپ دیگه در خدمتتون هستم.امیدوارم که از این استفاده کافی رو ببرید.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace MaximomAndMinimomNumberInListprogram98.com
{
static class Program
{
private static void Main()
{
// Sample 1:
Console.WriteLine("... Sample 1");
var list = new List<int> { 1, 2, 3, 4, 5, 6, 7, 16, 17 };
// MAX
Console.WriteLine("MAX=>" + list.Max(z => z));
// MIN
Console.WriteLine("MIN=>" + list.Min(z => z));
// Sample 2:
Console.WriteLine("... Sample 2");
// MAX
Console.WriteLine("MAX=>" + list.Max());
// MIN
Console.WriteLine("MIN=>" + list.Min());
// Sample 3:
Console.WriteLine("... Sample 3");
var list2 = new Dictionary<int, string>
{
{ 1, "One" }, { 2, "Two" }, { 3, "Three" },
{ 4, "Four" },{ 5, "Five" }, { 6, "Six" },
{ 7, "Seven" }, { 8, "Eight" }, { 9, "Nine" }
};
// MAX
Console.WriteLine("MAX=>" + list2.Max(z => z.Key));
// MIN
Console.WriteLine("MIN=>" + list2.Min(z => z.Key));
// Sample 4:
Console.WriteLine("... Sample 4");
// MAX
Console.WriteLine("MAX=>" + list.OrderByDescending(x => x).First());
// MIN
Console.WriteLine("MIN=>" + list.OrderBy(x => x).First());
// Sample 5:
Console.WriteLine("... Sample 5");
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace MaximomAndMinimomNumberInListprogram98.com
{
static class Program
{
private static void Main()
{
// Sample 1:
Console.WriteLine("... Sample 1");
var list = new List<int> { 1, 2, 3, 4, 5, 6, 7, 16, 17 };
// MAX
Console.WriteLine("MAX=>" + list.Max(z => z));
// MIN
Console.WriteLine("MIN=>" + list.Min(z => z));
// Sample 2:
Console.WriteLine("... Sample 2");
// MAX
Console.WriteLine("MAX=>" + list.Max());
// MIN
Console.WriteLine("MIN=>" + list.Min());
// Sample 3:
Console.WriteLine("... Sample 3");
var list2 = new Dictionary<int, string>
{
{ 1, "One" }, { 2, "Two" }, { 3, "Three" },
{ 4, "Four" },{ 5, "Five" }, { 6, "Six" },
{ 7, "Seven" }, { 8, "Eight" }, { 9, "Nine" }
};
// MAX
Console.WriteLine("MAX=>" + list2.Max(z => z.Key));
// MIN
Console.WriteLine("MIN=>" + list2.Min(z => z.Key));
// Sample 4:
Console.WriteLine("... Sample 4");
// MAX
Console.WriteLine("MAX=>" + list.OrderByDescending(x => x).First());
// MIN
Console.WriteLine("MIN=>" + list.OrderBy(x => x).First());
// Sample 5:
Console.WriteLine("... Sample 5");