DEV Community

Discussion on: Learn C# Programming with Me (Introduction)

Collapse
 
faranaiki profile image
Muhammad Faran Aiki

I learned C# thanks to Unity; although, I do not use Unity anymore. The syntax is similar to C, just how some classes and functions are presented differently (well, this is obvious).
C,

// Simple
#include <stdio.h>

void main() {
    printf("Hello, World!");
}
Enter fullscreen mode Exit fullscreen mode

C#,

// Little bit complicated
using System;

namespace Discussion {
    class Comment {
        static void Main(string[] args) {
            Console.WriteLine("Hello, World!");
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

The difference, though, is that in C, char arg[] is an array, whereas in C# it would be, char[] arg (just a comparison, maybe not a real object).

Collapse
 
abeck617 profile image
Anthony Beckford🚀

Wow this is actually a nice comparison. How were you able to get such a nice clean snippet of the code?

Collapse
 
faranaiki profile image
Muhammad Faran Aiki

I made it myself and try to minimize as minimum as possible. I am not superb at algorithm, even though math is like my main focus. When it comes to minimize a code, maybe I can do it better.

Collapse
 
saint4eva profile image
saint4eva

using System;

Console.WriteLine("Hello, World!);

Collapse
 
faranaiki profile image
Muhammad Faran Aiki

Namespace live matters in C#.

Thread Thread
 
saint4eva profile image
saint4eva

The above code snippet is correct. It is a new C# featrue called Top-Level program. It is supports .NET 5

Thread Thread
 
faranaiki profile image
Muhammad Faran Aiki

I did not know that; yes, you are right. When I try to compile it in .NET 5 in dotnet.microsoft.com/platform/try-..., it is working.

Thread Thread
 
saint4eva profile image
saint4eva

Yes, the .NET team is simplifying C# and making it even more succient and pleasant to use. The team is simplifying the asp.net core framework as well.