DEV Community

umida5
umida5

Posted on

Namespace

a) using System; bu kodning vazifasi nima?

using System; C# dasturlash tilida standart kutubxonaning System nomli nomlar fazosini (namespace) kiritish uchun ishlatiladi. Bu kutubxona turli xil asosiy funksiyalar va sinflar, shu jumladan:

Ma'lumot turlari (masalan, int, string, bool)
Klasslar va interfeyslar (masalan, Exception, DateTime)

using System; – bu kodning qulayligini oshirish va System sinflarga tez va oson kirish imkonini berish uchun ishlatiladi.

b)Quyidagi kod qaysi xato beradi va uni qanday tuzatish mumkin?

namespace MyApp
{
  class Program
   {
      static void Main()
      {
        Console.WriteLine("hello world");
      }
    }
}

Enter fullscreen mode Exit fullscreen mode

bu kodda xato class programni va static void Main ni ham alohida namespace dan tashqarida yo'zish kerak edi,chunki namespace ichida Sinflar, interfeyslar, strukturalar va boshqa elementlar ishlatiladi.Lekin class Program va main hech qachon namespace ni ichida yozilmaydi.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

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

Okay