Reja: kirish asosiy qisim 1 C#da satrlar


Download 21.42 Kb.
bet3/7
Sana18.06.2023
Hajmi21.42 Kb.
#1580878
1   2   3   4   5   6   7
Bog'liq
Reja kirish asosiy qisim 1 C#da satrlar-fayllar.org

C # oddiy satrlar

Oddiy satrlar talqin qilinadigan yangi satr yoki tab belgisi kabi qochish tartibini o'z ichiga olishi mumkin. Doimiy iplar er-xotin tirnoqlari orasiga joylashtirilgan.
Program.cs
using System;
using System.Text;

namespace RegularLiterals


{
class Program

{
static void Main(string[] args)


{
string s1 = "deep \t forest";

string s2 = "deep \n forest";


Console.WriteLine(s1);
Console.WriteLine(s2);
Console.WriteLine("C:\\Users\\Admin\\Documents");
}
}

}


Misollar ketma-ketlikni o'z ichiga olgan ikkita satrni bosib chiqaradi.
Console.WriteLine("C:\\Users\\Admin\\Documents");
Misol bilan ishlaganda yo'llar, shlaklardan qochish kerak.
$ dotnet run
deep forest
deep

forest
C:\Users\Admin\Documents


Bu natija.

C # so'zli satrlar
Verbatim satrlari qochish tartibini izohlamaydi. Verbatim satrlari @ belgisidan oldin. Verbatim satrlari ko'p qirrali chiziqlar bilan ishlashda ishlatilishi mumkin.
Program.cs
using System;
namespace VerbatimLiterals
{
class Program

{
static void Main(string[] args)


{
Console.WriteLine(@"deep \t forest");

Console.WriteLine(@"C:\Users\Admin\Documents");


var text = @"
Not marble, nor the gilded monuments
Of princes, shall outlive this powerful rhyme;
But you shall shine more bright in these contents
Than unswept stone, besmeared with sluttish time.";
Console.WriteLine(text);
}
}

}
Ushbu kod misolida biz og'zaki satrlar bilan ishlaymiz.


Console.WriteLine(@"deep \t forest");
Maxsus belgi talqin qilinmaydi; u faqat konsolga chop etiladi.
Console.WriteLine(@"C:\Users\Admin\Documents");
Biz so'zlar bilan ishlaganda so'z satrlari qulay; zarbalardan qochish shart emas..
var text = @"
Not marble, nor the gilded monuments
Of princes, shall outlive this powerful rhyme;
But you shall shine more bright in these contents
Than unswept stone, besmeared with sluttish time.";
Verbatim satrlari bizga ko'p satrlarni yaratishga imkon beradi.
$ dotnet run
deep \t forest
C:\Users\Admin\Documents
Not marble, nor the gilded monuments
Of princes, shall outlive this powerful rhyme;
But you shall shine more bright in these contents
Than unswept stone, besmeared with sluttish time.
Natija.


Download 21.42 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling