লোড হচ্ছে…

অনলাইন C# কম্পাইলার ও প্লেগ্রাউন্ড

ব্রাউজার-ভিত্তিক কম্পাইলার ও প্লেগ্রাউন্ড, C#, Progsity IDE।

C# সম্পর্কে

C# হলো .NET এর মূল language। Desktop software, web backend, আর Unity দিয়ে বানানো বেশিরভাগ game এতেই লেখা। Java র মতো এখানেও type আগে থেকে ঠিক করা থাকে, সাথে আছে collection নিয়ে কাজের জন্য LINQ আর বড় একটা standard library।

এখানে আপনার file compile হয় Mono র C# compiler দিয়ে, চলে sandbox এর ভেতরে Mono runtime এ। তাতে পাচ্ছেন C# 7 আর পরিচিত .NET class library: System, System.Linq, System.Collections.Generic, আর BigInteger এর জন্য System.Numerics। Top-level statement বা record এর মতো নতুন syntax এই compiler এ নেই, তাই একটা class এর ভেতরে static Main রাখুন।

Judge ও C# চালায় এই একই toolchain এ। Submit করার আগে solution টা এখানে একবার চালিয়ে দেখে নিতে পারেন।

কীভাবে ব্যবহার করবেন

  1. একটা class এর ভেতরে public static void Main() রাখুন। Class এর নাম যা খুশি দিতে পারেন।
  2. Input টা stdin panel এ লিখুন, code এ Console.ReadLine() দিয়ে পড়ুন।
  3. Run চাপুন। Compiler error এ line, column আর একটা CS code থাকে, সেটা দিয়ে search করলে ব্যাখ্যা পাবেন।

প্রশ্নোত্তর

এটা C# এর কোন version?›

C# (Mono 6.8)। Mono র compiler C# 7 পর্যন্ত বোঝে: tuple, pattern matching, local function, string interpolation আর async সবই আছে।

এটা কি .NET 8?›

না, এটা Mono, .NET Framework এর একটা open implementation। Standard class library র মধ্যে থাকলে code একইভাবে চলে। C# 8 বা তার পরে আসা feature এখানে compile হবে না।

BigInteger ব্যবহার করা যাবে?›

যাবে। উপরে using System.Numerics; লিখে দিন। Compiler কে reference আগে থেকেই দেওয়া আছে।

NuGet package install করা যায়?›

না। Sandbox এ network নেই, আর program মানে একটাই file, যেটা standard library দিয়ে compile হয়।

Code save আর share করা যায়?›

যায়, sign in করা থাকলে। শুধু run করতে account লাগে না।

কোড উদাহরণ

উপরের এডিটরে উদাহরণ লোড করতে “এটি চেষ্টা করুন” ট্যাপ করুন।

  • Array র ওপর LINQ

    using System;
    using System.Linq;
    
    public class Program
    {
        public static void Main()
        {
            int[] nums = { 3, 1, 4, 1, 5, 9 };
            Console.WriteLine(string.Join(" ", nums.OrderBy(n => n)));
            Console.WriteLine(nums.Where(n => n % 2 == 1).Sum());
        }
    }
  • দুটো সংখ্যা পড়া

    using System;
    
    public class Program
    {
        public static void Main()
        {
            string[] parts = Console.ReadLine().Split(' ');
            long a = long.Parse(parts[0]);
            long b = long.Parse(parts[1]);
            Console.WriteLine(a + b);
        }
    }
  • Dictionary দিয়ে শব্দ গোনা

    using System;
    using System.Collections.Generic;
    
    public class Program
    {
        public static void Main()
        {
            var count = new Dictionary<string, int>();
            foreach (var word in "to be or not to be".Split(' '))
            {
                count[word] = count.ContainsKey(word) ? count[word] + 1 : 1;
            }
            foreach (var pair in count)
            {
                Console.WriteLine(pair.Key + ": " + pair.Value);
            }
        }
    }
  • BigInteger দিয়ে 30 factorial

    using System;
    using System.Numerics;
    
    public class Program
    {
        public static void Main()
        {
            BigInteger f = 1;
            for (int i = 2; i <= 30; i++) f *= i;
            Console.WriteLine(f);
        }
    }