DEV Community

umida5
umida5

Posted on

Loops(Advanced)

break va continue operatorlari

for siklida break va continue operatorlari yordamida siklni to‘xtatish yoki keyingi iteratsiyaga o‘tish mumkin.

  • break siklni butunlay to‘xtatadi:
for(int i = 0; i < 10; i++)
{
    if(i == 5)
    {
        break; // 5 ga yetganda sikl to‘xtaydi
    }
    Console.WriteLine(i);
}
Enter fullscreen mode Exit fullscreen mode
  • continue siklni to‘xtatmay, faqat keyingi iteratsiyaga o‘tadi:
for(int i = 0; i < 5; i++)
{
    if(i == 2)
    {
        continue; // 2 ni chiqarib yuboradi
    }
    Console.WriteLine(i);
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay