How hard is C# to learn?

In second semester I will have programming in C# at my university. From experiences from older students it is hard if you don’t already have some better knowledge about programming. I have basic knowledge in C++, but VERY basic. I want to prepare myself for C# before february when this course starts, and my problem is that a lot of my coleagues from university are going on paid, certified course (recommended by older students) which I want to avoid because of it’s price. My question is how hard is C# to learn by free sources (internet, books) by february so I can avoid paid course.

I never considered it hard, but I had a heavy programming background before hand.

Unfortunately, this is an opinion question, so there isn’t a clear answer.

1 Like

The difficulty level is rather moderate. It is a lot easier than C++ or any unmanaged language, because you don’t deal with any manual memory management or pointers, where the only concerns you have regarding memory allocation/deallocation come down to performance. Performance isn’t all that concerning though while you’re just starting to learn the language, as you’re focused on just getting some functional code written down at that point.

The hardest part of learning C# in my opinion is understanding references and how they differ from value types. You’ll be using references all the time, using references to get to references to get to other references, etc, etc. In C# you use the same syntax though with references as you do with value types, but the effect of that code is very different. It takes a little while before you can look at a script and immediately spot the references from the value types. Expect to do a lot of googling for “in C# is XXXX a reference or value type” for a while.

For example, the effect of the following code is very different

int myInt = 7;
int myAnotherInt = myInt;
myInt = 6;
Debug.Log(myInt.ToString() + " : " + myAnotherInt.ToString();

The above will output “6 : 7” to the console.

SpecialInt myInt = new SpecialInt();
myInt.mySpecialInt = 7;
SpecialInt myAnotherInt = myInt;
myInt.mySpecialInt = 6;
Debug.Log(myInt.mySpecialInt.ToString() + " : " + myAnotherInt.mySpecialInt.ToString();
public class SpecialInt
{
    public int mySpecialInt;
}

This above will output “6 : 6” to the console, not “6 : 7”, because in this example myAnotherInt is a reference type instead of the first example where it is a value type. Can take a little while to wrap your head around this when just starting, and it is really easy to expect one thing and find out your code does another.

1 Like

Can you recommend any free site or youtube for tutorials?

Shouldn’t be hard to search for some, as C# is one of the most popular programming languages right now. I can’t make a specific recommendation because I learned C# back in ancient times when people would actually use books to learn skills, newspapers to learn what is happening in the world, and phone lines to connect to their AOL account :stuck_out_tongue:

I know I used c# step by step back in the day. I had an intro course that was going way to slow, so I picked up the book.

Brackeys, speedtutor, and many others are good sources on youtube.

I feel so young :smile:
I have bad experiences with books for learning programming. I started to read 2 books in my native language but it was total failure, I had tough time understanding some parts, videos have better impact on me

Thanks for advice

If you really have a very basic understanding what programming and programming languages are, then this may help you. But please, follow along.

https://www.youtube.com/watch?v=r_5P6GVYJpY

1 Like

I haven’t tried it out myself but I’ve received good feedback form others I’ve pointed here. This is a free series from Microsoft.

C# Fundamentals for Absolute Beginners | Microsoft Learn!

1 Like

Speaking of Microsoft, I remember reading this blog post of updated tutorials

1 Like

Wow. Back in the day C++ was a good starter language. It still is, but you don’t see it as much now. I’ve got a few pages of C# for C++ programmers at http://www.taxesforcatses.com/codeNotes/csForCpp.pdf. It’s really for someone who knows up to pointers, but it’s a mix of everything.

I’ve found most C# sites are about syntax – how to use the latest things in 7.0, that you don’t really need. But an advanced class often relies on just begin good at programming in general. "Here’s problem X, which can obviously be solved with this nested loop over an array, but today we’re going to solve it by… ".

Also, curious, is there a Unity connection here?

Since others already send you some fine tutorials and sources, here a bit more general advice:

All programming languages have some concept for (different) types, assigning values to them, creating arrays/lists of types and iterating over them (or other code blocks) with loops.
If you have some basic experience with C++, then i guess you have seen most of the above. If one of those things is new, then look up some C# examples and try getting a grasp of these basic concepts. Writing some code yourself or even starting a little (game) project (we are on a Unity forum after all ) can help boosting your confidence immensely.
With a good understanding of the above concepts you are already able to “programm anything” you want.

Here some advice on what i think would be the most important types, loops, … and so on, to have a look at for now.
Basic types: int, float, and possibly strings (Vector and so on in Unity)
Arrays & Co: normal arrays ([ ]), Lists, possibly jagged arrays ([ ][ ])
Loops: imho you only need to look at the normal for-loop for now

After you are done with the basics, you will still need to take a close look at object-oriented programming, because that’s how things are done nowadays, C# is considered an object-oriented language, and it will most certainly be a big part of your exercises. Try getting a grasp of how we use objects to represent groups of data, how different classes and instances of objects can relate to others, and how you create/access their methods and generally do stuff with them.

If you can do all of the above in C# (which really is not that different from C++, Java, or other OO languages), then i’d say you are pretty well prepared for the exercises in your semester. Even tho, i’d be very surprised if they didnt at least give you some introduction to all of this.

1 Like

I learned it from a library book:
Learning C# 2005, Second edition by Jesse Liberty and Brian MacDonald. Copyright 2006 O’Reilly Media, Inc, 0-596-10209-7.

Everything in my notes is still very relevant to the latest versions of C#. I suggest downloading the free version of Microsoft’s Visual Studio for C#, it is a very good Implementation Development Environment (IDE). Dlang.org has a link to a book on D that also teaches a lot about computer programming and it would also be a useful resource for learning techniques. You can also get a fair amount of information on C# (and other languages) at www.codeproject.com

There is a second book in the series of the first one I mentioned, something like “Advanced Programming in C#”. I recommend tracking that down if you can, and if you have the time. Write a simple app or two, that will give you a good grounding so you will be ready for the course.

Hmmm… it occurs to me that the class probably has a textbook, which is probably obtainable now. The whole thing is weird. What kind of class requires a non-school prep class?

I can imagine the first day has: class A { int x { get; set; } }. You’ve got to just know that’s C#-speak for: class A { public int x; }. Or min(x:3, y:6), or foreach, or that crazy expression-bodied thing. The class itself could be not-too-hard, but seem incomprehensible if you haven’t looked up all that fancy stuff.

I was responding to the original poster who wanted to know how to learn C# fairly easily with a relatively low level of experience in both the language and programming. The book I referred to is old enough to be in many libraries, or obtainable by them. I did my best to help him be able to find and use free resources. Tuition, books and living expenses are high for students and profit opportunities tend to be low.

Yes, he could learn from code snippets here in the forums, but even faster with a good book, or three.

If you read a little extra, that person will be taking a C# class. They’re not wanting to learn C# on their own, they’re wanting to know how to prepare for the class. When you mentioned a book in general, it reminded me that the simplest, most common way to prepare for a class is to look over the book ahead of time.

Yes, but the University Book stores don’t usually have the book in stock until right before the class. So if you want to prepare ahead of time, you can study up using the abundant free resources that are out in the world outside of the Universities.

People are right that it really is a matter of opinion, so asking if C# is ‘hard’ is pretty generalised, if we’re talking about programming the one thing I found utterly ridiculous was the vocabulary. Once I got myself a glossary though, it was like a whole new world had opened up for me and I was going through tons of tutorials and documentation like crazy and I still blaze through it now.

As for the language itself, it’s like any other, it’s got it’s own weird quirks you’ve got to work out just by going through tutorials and doing some projects.

1 Like