C# tili CLS(Common Language Specification) ga mos keladigan keng tiplar to`plamini taqdim etadi. Bu tiplar NET platformasiga mos keladi yani C# da hosil qilingan obyektlar NET CLS qo`llab quvvatlaydigan har qanday dasturlash tilida foydalanish mumkin (masalan VB.NET). Har bir tip aniq o`zining o`zgarmas o`lchamiga ega. Quyida C# tomonidan taqdim etilgan tiplar ro`yhati jadvalda keltirilgan:
Yuqoridagiga qo`shimcha tarzda C# da yana enum, struct tipidagi obyektlar ham bor.
class Program {
static void Main()
{
Console.Write("A katetni kiriting: ");
double a = double.Parse(Console.ReadLine());
Console.Write("B katetni kiriting: ");
double b = double.Parse(Console.ReadLine());
double C = Math.Sqrt(a * a + b * b)
double P = a + b + C;
Console.WriteLine($"Gipotenuza (C) = {C}");
Console.WriteLine($"Perimeter (P) = {P}");
}
}
3-masala
using System;
class Program
{
static void Main()
{
double pi = 3.14;
Console.Write("Uzunlikni kiriting (L): ");
double L = Convert.ToDouble(Console.ReadLine());
double R = L / (2 * pi);
double S = pi * Math.Pow(R, 2);
Console.WriteLine($"Radius (R) = {R}");
Console.WriteLine($"yuza (S) = {S}");
Console.ReadLine();
}
}
4-masala
using System;
class Program {
static void Main()
{
Console.Write("A ni kirit: ");
double pointA = Convert.ToDouble(Console.ReadLine());
Console.Write("B ni kirit: ");
double pointB = Convert.ToDouble(Console.ReadLine());
double distance = Math.Abs(pointA - pointB);
Console.WriteLine($"JAvob: {distance}");
Console.ReadLine();
}
}
5-masala
using System;
class Program {
static void Main()
{
Console.Write("Gradusni kiriting (0° < α < 360°): ");
double degrees = Convert.ToDouble(Console.ReadLine());
double radians = degrees * (Math.PI / 180);
Console.WriteLine($" {degrees}° gradus {radians} ga teng bo'ladi.");
Console.ReadLine();
}
}