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
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).
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.
I learned it because I had to write a WPF desktop application, so you could start with WPF tutorials. I was already very familiar with Java, which is very similar, so it wasn't too hard. Last time I used it was in Unity. You might want to find a good free online course for C# to get a good grasp of C#/Java's style of OOP, design patterns, and all that kind of stuff.
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.
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#.
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.
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.
Code is overwhelming. Even experienced professionals hate diving in to somebody else's code. It's scary, poorly documented and we always think we could have done it better.
Don't let that put you off.
A lot of us are practical learners. So like you we stare at a wall of code but struggle to comprehend it. But if you dive in and start editing, experimenting etc you'll change the output and understand why it was written in a certain way.
Eventually once you've got it sussed you'll be able to adapt a script to do what you want it. That'll trigger the dopamine reward mechanism and you'll be hooked like the rest of us.
It sounds like you either have not integrated ChatGPT into your life yet or you'd never think of asking a tech-tool tech-related questions.
All my code in the last year has been written up by AI. Sure, for now you still need to know what you're doing, the code pretty much always needs adjustments, but your first draft is never farther than one LLM query away.
If you tell him what you just told us, like "I've spent months and all I can do is parse some values, what could I code to expand my horizon?" you will have new angles in minutes and all key lines of the code will be explained to you.
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
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?
I did not choose C#, and after Python, i'd have chosen Javascript, Lua, or Java if it was my choice. I learn it in school, for some reason. My teacher is not very good at explaining things and basically leverages everything on us without teaching how to do it. And also, we learn c# once a week, which is propably not the intended way to learn a programming language anyway, and even then, most lessons are about flowcharts, number systems. Anyone who can learn c# in this enviroment is an absolute genius. Of course the whole class struggles with it
So... When you first start leaning to code you need to learn a lot of concepts, not just the language.
Flowcharts help to teach about code flow, conditionals, loops, etc.
You may be concentrating too much on language specifics. You're not learning C# - you're leaning to program using C#. There is a lot of theory behind programming languages.
Getting exposure to the language only once a week will definitely hinder you a lot. When learning a language, there's a bunch of stuff you'll memorize without even thinking about it if you spend time working on it every day, but it will be hard to remember if you spend a week between learning sessions.
Make a text adventure game that runs in the console.
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.
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.
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.
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.
Aurora is the engine Neverwinter Nights ran on. The scripting system was driven by C#. The guidebook was the official "strategy guide" but for the toolset, not the game itself.
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.
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
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.
Ok, so if is for school, what is the context? Is a class about C#, about OOP, or programming languages, or creating a website or creating a videogame. I'll try to cover different focuses.
C#, if is just about the language, I'd think is a bit strange, I feel that at school level you want to relate a programming language to a more fundamental concept that you can find in other languages as well, rather than sth this specific. Anyway, things like memory management: memory allocation, value/reference, garbage collection, or things like async/await, Tasks, LINQ, polymorphism, the different types and keywords and the .NET framework are important at this level.
C# is a multi paradigm language so you can implement stuff mainly in OOP, but also functional, imperative and others, I'm going to assume that the idea is to use it more as OOP, if you have used already OOP in Python you just need to find what are the features and constraints of C# around this compared with Python.
A console project may help you to understand these concepts, but at the end it will depend in what you want/need to learn to focus on what kind of project is better to implement for learning.
If is just the concepts in OOP in C# any simple project can help you on that, for instance you can use a Code Kata and you can add specific requirements about covering OOP concepts so you force you to learn and practice that, even if is over engineered.
If your plan is more related to a project implementation, that's a different story, because now you have to consider not just the building process, but also the deployment process, so not just about the language, and in this it matter less some specific stuff about the language and more about how to implement some stuff using already libraries, so is more about putting things together having in mind good practices, and also how you pack the binaries and distribute them. Other stuff, where the app will run, how do you monitor your app while is running, do you need persistence? Do you need logging, do you need security, etc.
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.
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
You propably don't know how bad i'm in C#. Basic console apps are giving me trouble. I think it is very different from python. Like nothing is the same, at all
I sure don't sound helpful saying this, but it's mostly about finding the equivalent to the python action/types, and typing them out when making functions and variables. Though 99% of the time, you are completely fine defining variables as var to avoid excessive typing.
I assume you dealt a bit with classes in python, if not then you're doing double time with both changing language and learning object oriented classes at the same time.
If there is any specific I can try to give some clarity since I also came from Python to C#.
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.
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.
Depends how you learn. Being mindful of what your goal is helps. C# can be used for console apps, it can also be used to make ASP.Net websites, further afield you can program the Unity games engine with C#. Each of these will have "absolute beginner most basic first steps" type tutorials out there. They'll all have some similarity as you'll need to just learn the C# syntax one way out another, but it miles easier doing this if you're vaguely interested in the types of apps you're heading towards.
If all else fails, message me, I was there once, about 20 years ago..
My first projects were super janky gui stuff that was ported over from Java (very similar syntax, but connected with the visual studio built-in gui editor) and improved to a proper "c#" style using resharper (a jetbrains tool that boosts the capabilities of visual studio)
Nowadays you can get a free version of Rider that will include those style tools, so I'd recommend that.
But if you use Visual Studio, you can create a Winforms project which can let you drag components to make UI and easily assign code to events.
If you are used to raw HTML webpage creation, you might be able to get away with using something like WPF or (cross platform) Avalonia to make a UI, but these are a bit more intense since they use something called the Model-View-Viewmodel framework. It needs you to know how to 'bind' variables to events using the observable class, which can be tricky the first few times you use it.
I'd look into picking a simple project where you can learn how to use classes effectively (C# is based around Object Oriented Programming much more than bash and self-taught Python would cover). Also would recommend following some of the very simple Unity tutorials to get a handle on the syntax, such as the Unity-made Roll-a-Ball tutorials. These tutorials show the concepts for class-based design and overriding functions.
Jumping from loose-typed language to strict-typed language will be hard.
It's also a matter of your general programming experience. Once you write, like, ten thousand lines of meaningful code in Python, learning C# should take you a month or two at most, you'll know most programming concepts and algorithms intrinsically, and the rest is just learning syntax.
Well yeah. You find yourself some simple project and try to build it. When you don't know how to do something, you look it up.
Like, make a command line clock, for example. Figure out how to get the current time, and then how to print it. And after that how to make it print the time once a second.
Edit: probably the most important skill in programming is breaking the problem into smaller pieces that you can then figure out. With experience, getting stuck like this becomes much less of a problem.
I considered saying the same thing, but C# has been around almost as long as Java at this point, and I believe it's commonly used for teaching, so I have a hard time believing there's a shortage of learning resources. Starting with Java seems like a waste of time if your goal is to learn C#, because you can learn the concepts equally well in either language, but if OP starts with Java they'll end up spending a lot of time unlearning Java quirks and APIs while learning the equivalent stuff for C#.
no, i don't think there is a big difference in 'difficulty' between both languages.
there is just more material for java, and as i said the languages are very similar, so learing to program in java wont be a waste of time if you plan to only use c# after that, because the concepts you learned a long the way will easily carry over.