Hey there, I’ve been interested in learning c#. Is it better to learn c# on it’s own or with Unity? Is it any different?
If your goal is to use C# in Unity, then learn it in Unity. First, Unity has a lot of really great coding tutorials for beginning programmers. Second, learning C# elsewhere will have you learning a lot of things that simply aren’t relevant in Unity coding and might make it harder to learn certain things in Unity.
For example, usually in C# you create objects with constructors. But in Unity, you create objects with Instantiate(), or .AddComponent; trying to use a constructor to create anything MonoBehaviour-based (which is going to be most of your Unity scripts) just plain doesn’t work. There’s also a lot of other ways Unity does things a little differently than the standard C# practices.
I would argue that it’s an easier path to learn the way C# is used in Unity and then once you have a handle on that, branch out to learn more generalized C# stuff. This is partly because Unity is just a really good environment to learn in, what with instant feedback/compilation and the plentiful beginner-friendly tutorials and references. (The biggest gotcha for learning Unity is that it has changed a lot over the last decade, so many tutorials which used to be great and have become high-ranking search results are now obsolete.) C# has a lot of great reference resources like MSDN, but MSDN is pretty dense for beginners, and beginner-focused generalized C# tutorials are harder to find than Unity-based C# ones.
The other side of the coin: Because Unity has its own standard practices, if your primary goal is to learn general C# and .NET programming, it would be better to go straight for that. You don’t want to get in the habit of using “the Unity way” for everything if no projects in your future are going to use Unity.
tldr:
If your main goal is to make games, learn C# in Unity.
If your main goal is to use generalized C#, learn generalized C#.
If your goal is to be able to do both, it’s probably easier to learn C# in Unity first and generalized C# later.
Alright, thank you!
A search will show this has been asked many times, and you’ll get every possible answer, without much agreement. Way back, Unity originally recommended a particular commuter science textbook to learn C#. Now, it has “Learn” but you’ll find opinions on it everywhere from “great” to “terrible”. Likewise, if you want to use a regular book, you’ll find no agreement on a good one.
I’d change StarManta’s advice just a bit: if you want to play with Unity now, and don’t mind some copy-paste to get something to happen, obviously, use Unity. If you’re getting frustrated that the C# rules seem just made-up and it’s like you’re randomly changing things until the computer likes it – find a textbook.
But the thing is, you can write “normal” C# programs in Unity, like something that prints 1 to 10. You can sort of learn C# on its own, in Unity.