this post was submitted on 04 Jan 2025
28 points (72.6% liked)

Programming

17843 readers
93 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
 

I have some background in Python and Bash (this is entirely self-taught and i think the easiest language from all). I know that C# is much different, propably this is why it is hard. I've been learning it for more than 4 months now, and the most impressive thing i can do with some luck is to write a console application that reads 2 values from the terminal, adds them together and prints out the result. Yes, seriously. The main problem is that there are not much usable resources to learn C#. For bash, there is Linux, a shit ton of distros, even BSD, MacOS and Solaris uses it. For python, there are games and qtile window manager. For C, there is dwm. I don't know anything like these for C#, except Codingame, but that just goes straight to the deep waters and i have no idea what to do. Is my whole approach wrong? How am i supposed to learn C#? I'm seriously not the sharpest tool in the shed, but i have a pretty good understanding of hardware, networking, security, privacy. Programming is beyond me however, except for small basic scripts

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 45 points 2 weeks ago* (last edited 2 weeks ago)

The heck you're talking about? There's a ton of free resources to learn the basics.

https://dotnet.microsoft.com/en-us/learn/csharp official Microsoft learning resources.

https://dotnettutorials.net/course/csharp-dot-net-tutorials/ for C# basics and .NET framework (which is backend standard).

For game engines you need specific tutorials in those engines.

[–] [email protected] 40 points 2 weeks ago (3 children)

You think Bash is the easiest language? I have to Google the syntax every time i need to write and IF statement!

[–] [email protected] 6 points 1 week ago

it's the second language that comes to mind when I think of the word "footgun", right after old c++

[–] [email protected] 5 points 2 weeks ago

Thisss, it's atrocious

[–] [email protected] 3 points 1 week ago

There's a few languages I come back to after a while to fix something and have to consult their reference manual / docs. But bash is the only one where that's necessary just to read back my own code. Like [[ -z ${ARG} ]]? Wtf is -z doing here. Wtf kind of syntax is that.

Next time I think oh this could be automated with a little bash scrip I'm going to investigate one of those compiles-to-bash languages.

[–] [email protected] 37 points 2 weeks ago (1 children)

one of the most popular languages, used in one of the most popular game engines, has no learning resources?

Press X to doubt

[–] [email protected] 3 points 1 week ago

Yeah but then you have to learn MATH and I'm not doing that.

[–] [email protected] 16 points 2 weeks ago (8 children)

It sounds like you'd benefit from having a project in mind. I always learned programming languages by building something I wanted, or by tinkering on someone else's project.

load more comments (8 replies)
[–] [email protected] 13 points 2 weeks ago (7 children)

Microsoft produces a plethora of good learning materials if you're struggling with the basics or specific concepts. I recommend their C# for Beginners course to get a good overview of real C#.

Once you have a good handle on the basics, I would echo others' advice that having some kind of project or goal to work towards is the surest path to learning, because you have external motivation to use what you're learning and look up things as you need them. Is there some reason you chose C# specifically as your next language, maybe for game dev, web dev, or Windows apps?

load more comments (7 replies)
[–] [email protected] 13 points 2 weeks ago* (last edited 2 weeks ago)
  1. Start writing a small game in Godot using GDScript (basically Python)
  2. Use the Godot docs to read about C# alternatives to GDScript as you go, compare them and see how they differ
  3. Translate bit by bit of your game to C# using the docs
  4. Congrats, you have written a game in C#
[–] [email protected] 11 points 2 weeks ago* (last edited 2 weeks ago)

Don't learn a language unless you need to use it for something.

That's why you're finding it hard. If you needed to program a game, decided on Unity, and had a specific thing to do, it would be easy to figure out how to do that in C#.

[–] [email protected] 10 points 1 week ago* (last edited 1 week ago)

People seem to be misunderstanding your question. It doesn't sound like you are lacking educational resources to learn C# but a lack of reasons. It sounds like you have been learning by getting you're hands dirty with foss software.

C# is a sort of "enterprise-grade language" like Java. It's meant for large applications developed by one or more teams for almost exclusively commercial purposes. If you want to learn it, deeply, you'll have to come up with an excuse to write in it. A game is probably the best choice for this. Then learning c# is learning how to make your game.

If you're looking for open source C# software to hack on you can try anything from the *arr stack. (Sonarr, radarr, lidarr).

[–] [email protected] 8 points 2 weeks ago (1 children)

Check out this reference (not mine): https://gist.github.com/DanielKoehler/606b022ec522a67a0cf3

The first difference that I would point out is c# use of static typing, where python is dynamic. This author is using the var keyword to avoid specifying a type for variables. The type is, instead infered by the code that follows the equals sign.

The next main difference is the use of whitespace. Python is very whitespace aware, it uses indentation and line breaks to organize code. C# is whitespace agnostic in most cases and separates blocks of code using curly braces {...}, statements must end with a semicolon;

In C# collections are organized by how the data is accessed and whether elements can be added or removed. Arrays are initialized with a set of items and can't be made longer, a List can be added to and can be removed. The key point is that all items in a collection are of the same type.

Complex objects (that have properties and methods) can be structs, classes, or records but they all basically do the same thing and interact in the samish way. You have to use the new keyword to make a new instance.

Classes and records can inherit from another where as structs cannot. Properties must have a type, methods must return a type or void. Method parameters must be typed, when calling a method the provided parameters must be of the proper type.

An interface describes requirements an implementing class, record or stuct must meet (i.e. properties and methods). You can't make a new interface, it's more of a qualification.

I hope this helps some

[–] [email protected] 3 points 2 weeks ago* (last edited 2 weeks ago) (3 children)

Is it bad if i barely understand anything in this comment?

[–] [email protected] 8 points 2 weeks ago (4 children)

Most probably, yes. A lot of these are fundamental concepts of most modern object-oriented languages that I am familiar with. It may be worth refreshing your basic programming skills/concepts with a book you like. There are plenty available online for free in C#, Java, C++, Go, etc.

load more comments (4 replies)
[–] [email protected] 5 points 2 weeks ago* (last edited 2 weeks ago)

Quite bad actually, since most of this stuff is not specific to c#, and are just basic programming concepts. This leads me to believe that your python experience is "coby and paste stuff in until it looks like it works", and you never took the time to understand what the code does.

[–] [email protected] 4 points 2 weeks ago

I wouldn't say it's that bad, it probably means you lack vocabulary rather than anything else.

[–] [email protected] 7 points 2 weeks ago

Tim Corey on YouTube has excellent beginner C# material. I would start there.

[–] [email protected] 6 points 2 weeks ago* (last edited 2 weeks ago) (4 children)

I found C# to pretty much be python just with strict types and semicolons. Jumped right into it really on my first job and it worked out pretty fine, granted I got to orient myself in the existing project where I started.

You are perhaps already familiar, but some things stand out like public/private annotations and other class related things like interfaces which work to create a more organized and controlled use compared to pythons "we are all consenting adults" approach were nothing ever really truly blocked from you. It depends a little on what you want to do/use it for, there's frameworks and different uses like WPF / .NET for the frontend.

While it may be too basic for you, ZetCode was useful for me back when learning PyQt in python, so you might find some use with the C# intro: https://zetcode.com/all/#csharp

load more comments (4 replies)
[–] [email protected] 5 points 2 weeks ago* (last edited 2 weeks ago)

For bash, there is Linux, a shit ton of distros, even BSD, MacOS and Solaris uses it. For python, there are games and qtile window manager. For C, there is dwm. I don't know anything like these for C#, except Codingame

It seems like you find an environment that requires the language and then kinda sink-or-swim? If so then yes, your whole approach is wrong. You need a process with a lot more structure. Get a Udemy course or a book from the library.

[–] [email protected] 5 points 2 weeks ago

Start with the goal to create something, be it a console app, website, web api, or game. It's hard to just study a language abstractly and learn it. Use the Microsoft Learn documentation as reference, and look for open source .NET projects on GitHub to get different perspectives on how to build things with .NET. There is a free course on freecodecamp that will get you started by building an app, and I believe it was done in partnership with Microsoft

[–] [email protected] 5 points 2 weeks ago (1 children)

Why you need or want to learn C#? I think depending on the answer we can find a good starting point on how to approach your learning because is not just about the language, also about the ecosystem.

[–] [email protected] 3 points 2 weeks ago (3 children)

Because it is required in my school. And we barely have any classes, even then, the teacher is not really good at teaching it. He thinks we will learn by copy-pasting it from the board. This is literally what we have to do in class. And for some reason, he is the principal

[–] [email protected] 3 points 2 weeks ago (1 children)

Do the other students feel the same way? It might be worth starting a study group amongst your peers to help one another out.

Have you reached out to your teacher? they should be able to either help you catch up or steer you towards resources that better suit your pace/ learning style.

[–] [email protected] 4 points 2 weeks ago

Yes, they do but we are not a good community, they are not really helpful. The teacher is the principal. He barely has time to come to the lesson, i doubt he has the time and intrest to care about students who can't understand what is going on. Plus he is not that approachable person, very strict and not that helpful

load more comments (2 replies)
[–] [email protected] 4 points 2 weeks ago

I have a Python background and I'm learning C# right now. Unity development is done in C# if your interested in games or 3D applications. There's a ton of resources for that kind of think out there and I find its a fun context to learn in. I've also had decent results recreating tutorials written for other languages using LLMs. Just start with step 1 as a premise and state the overall goal, then ask for incremental changes at each step an ask questions and for alternate solutions. Just watch out for those hallucinations.

[–] [email protected] 4 points 2 weeks ago
  1. Make a text adventure game that runs in the console.
  2. Tic tac toe in the console.

Then if you want to go for a GUI web app with react use "dotnet new react" and create a to-do list with a client/server setup.

If you want to learn to make games you could make a tic tac toe again but with a GUI in Godot.

Once that's done make tetris.

You research what you need right before you need it and use it immediately so it sticks better. You'll need to get comfy with typing systems and I recommend using an IDE like Rider or Visual Studio to program it since they help out a lot.

[–] [email protected] 4 points 2 weeks ago

C# was the first language I learned in school, there's plenty of beginner resources for it on Youtube. You can also try some projects using Windows Form Applications (janky but fun) or the Unity game engine, which has tons of resources online.

[–] [email protected] 4 points 1 week ago (1 children)

Starting with Visual Studio (not code) helps a ton. Make a simple winforms application with a button and some labels and you will start to see how it 'starts up' from program.cs to your form.

load more comments (1 replies)
[–] [email protected] 4 points 1 week ago (1 children)

An IDE with auto-complete would help a lot.

load more comments (1 replies)
[–] [email protected] 3 points 1 week ago

Start with "absolute beginner" courses. Here's one from Bob Taylor. He puts out a lot of good stuff.

Sit your self down and study it for a good bit, then build some things. https://youtu.be/0QUgvfuKvWU

[–] [email protected] 3 points 2 weeks ago (4 children)

I learned C# from the Aurora guide book I picked up with Neverwinter Nights back in the day.

load more comments (4 replies)
[–] [email protected] 3 points 1 week ago* (last edited 1 week ago)

When I was learning c#, I found the .Net framework tutorials available on freecodecamp to be good.

Also, using the Jetbrains Rider IDE (assuming this is for private non-commercial purposes, as per the terms of their free license) rather than VSCode or Visual Studio. VSCode is still lacking in features when it comes to c#, and Visual Studio probably makes more sense if you're already accustomed to c# dev.

[–] [email protected] 2 points 2 weeks ago (1 children)

Java and C# are very similar, worst case scenario learn Java, then C# will be easy.

[–] [email protected] 7 points 2 weeks ago

That's a waste of effort IMO C# is a bit easier imo

load more comments
view more: next ›