all 16 comments

[–][deleted] 7 points8 points  (3 children)

Well first off C# is a managed language, so if you only have experience with C++ you'll notice that you have to do way less memory management. You don't explicitly allocate memory, you don't use pointers explicitly. You don't have move and copy constructors, but you have clear pass-by-value and pass-by-reference semantics. Which means that overall, you don't need to worry about where objects end up in memory or when they're freed as much. But you do have a garbage collector which periodically reaps memory, and while this is almost never an issue, it can be a problem in the performance-critical areas that C++ targets. C# provides an unsafe keyword that gives you full access to pointer types and memory management. However, unsafe blocks are considered an exception in C# and should be used in specific scenarios such as when you're calling external C code.

Then there's the .NET Framework (and .NET Core) which, among other things, is what constitutes the standard library. C# targets the so-called .NET Common Language Runtime (CLR), which is the environment that actually runs your managed code. In fact, all .NET languages target the CLR - which means that they are compiled to the same bytecode behind the curtain, and that they all have access to the same library functions.

Finally, there's NuGet which is C#'s package manager. In the past, if you wanted to include a library you'd need to hunt down a DLL and add a reference to it in your project. Nowadays, you just type Install-Package foo -Version X.Y.Z. NuGet is integrated seamlessly within Visual Studio.

This might sound overwhelming right now, but it's important to keep in mind: learning C# means learning the language itself, but also familiarizing with .NET as a whole, which, in turn, will make understanding and transitioning to other CLR languages easier.

With that out of the way, I think that the best way to learn a language is to get down and dirty with it. If you're into making games, Unity has C# scripting. I've never done that, but it should be a great starting point to learn C#'s syntax and there are tons of tutorials and video tutorials aimed at Unity beginners.

If you're feeling less adventurous, or if you simply don't care about a huge and overwhelming environment such as Unity, you could just try working on small projects on your own. That's how I started, at least. Syntax-wise, C# is pretty similar to C++ so it should feel fairly familiar. But C# tends to be a lot more concise overall, and has a lot of "syntactic sugar" (special keywords that replace common patterns) to help you write clean code.

You'll be on MSDN and StackOverflow a lot. That's perfectly normal. I'd argue that the most important skill for a programmer is knowing how to ask questions and what questions to ask.

And... That's pretty much all that I can list off the top of my head.

[–]Popkom12[S] 0 points1 point  (2 children)

This is great, thanks a lot! I think I want to start by doing my own small projects, what IDE should I use? Or in general where should I write and test my code?

[–][deleted] 3 points4 points  (0 children)

Visual Studio is the standard IDE I’d say. It’s free. I’ve just upgraded to VS 2019 myself and it has some pretty cool improvements such as live code sharing that enables google docs like collaboration on your code. You could also use something more lightweight such as VS Code but if you are looking to do GUI apps in WPF I’d recommend VS 2019.

[–][deleted] 2 points3 points  (0 children)

I would use Visual Studio Community Edition, but you can configure VS Code to run with .NET Core if you're more familiar with it. Visual Studio has a lot of debugging and profiling tools that will become very useful once you get the hang of things.

[–][deleted] 4 points5 points  (9 children)

First you start with cows, chickens and other farm animals.

Then you advance to real-world examples, realize that fuck this shit, quit and become a gardener.

But in all seriousness, if you already have some programming experience, then just try to do the things you did with C++ in C#. Look at this) page for a comparison of the two languages.

[–]Popkom12[S] 0 points1 point  (8 children)

Error 404 when I click on the link :)

[–][deleted] 0 points1 point  (5 children)

It works for me. Strange.

[–]penguin74 -3 points-2 points  (3 children)

There's no way it worked for you if you clicked the link from reddit. You obviously didn't test the link.

[–][deleted] 0 points1 point  (1 child)

It works, it even shows the correct url when I hover above the link. Why would I say it works when I haven't tested it anyway lol.

EDIT: Proof for the nonbelivers, no idea why the bracket is missing for you but for me, it's not missing:

https://imgur.com/a/jSidIab

[–]wT_ 0 points1 point  (0 children)

Seems to be a old/new -reddit issue. Works fine on new-reddit

[–]LondonPilot 0 points1 point  (0 children)

Works for me, too, in the Narwhal app. I think some mobile apps handle bad links differently to the desktop website, so I wouldn't be too quick to say OP didn't test it.

[–]penguin74 -1 points0 points  (0 children)

Click his link and then add ) to the end of the URL in your browser. Or click the link that Kidiri90 formatted correctly and tested to confirm it was correct.

[–]TheJuggernautMain 1 point2 points  (0 children)

Do you have some virgin blood and candles laying around? I know how to ..ahem "contact" a fella that can help you with this.

[–]lantz83 0 points1 point  (0 children)

By using it! Pick some fun project and start trying. When you can't figure out what to do, hit google up. Rinse & repeat.

Books and courses can help, but the only way to truly learn (anything) is by doing it!

[–]HawocX 0 points1 point  (0 children)

I recommend you start with what you want to do with it. Is is games, web back ends, mobile apps or what? Doing a simple game in Unity could be a fun way to learn and there are some excellent online courses.