Is it me or is C# hard?

VitzzViperzz

Well-known member
Joined
Jan 16, 2017
Messages
75
Location
United Kingdom
Programming Experience
1-3
Hello,

So I've been following this C# book for beginners and at the end of every chapter that we get to, the author gives a few challenges. Now I have a good idea of how to start these challenges, but I never seem to complete them. I also seem to forget things like implicit and explicit conversions very easily as well.

I wanted to ask, if I should go back to the start and just start again and build an ever stronger foundation, or if I will gradually get better? I don't think I am the most naturally talented programmer.

What should I do? How did you learn, I would like to hear your opinions.

Cheers
 
To answer the question in the title, it's not just you as C# is hard but it may be partly you as you admit that you're not a natural at programming. If you've never done any programming before then learning programming concepts, .NET concepts and C# concepts all at the same time is undoubtedly going to be a challenge and it will be more of a challenge for some than others. Based on what you've said, I'd suggest that going back and starting again may well be a good idea, if you've got the time. It's quite possible that you have picked up some stuff along the way that you haven't even realised so things that seemed baffling the first time will now click, which makes other things click and then you may be significantly better equipped when you get back to where you are now.

One thing that can help or hinder is how you look at things. Programming doesn't exist in a vacuum and object-oriented programming particularly is based on the real world of objects that we live in. For instance, people often don't understand the concept of casting and why it's necessary so I use analogies this the following. Imagine that you're a vet and someone brings a box into your examination room. You're a vet so you know that it's an animal in the box but that's all. As a result, the only things you can do to or for that patient are things that apply to all animals. If the person then tells you that their animal is a cat then you now can reasonably do all those things that apply specifically to cats. In C# parlance, you had an Animal variable and it was cast as type Cat. Note that the object itself never changed, i.e. the cat was a cat the whole time. The term "cast" is used in the sense of "casting something in a different light", i.e. looking at the same thing in a different way. Obviously there's more to programming than just this but the more you can draw analogies to the real world, the clearer things become.
 
To answer the question in the title, it's not just you as C# is hard but it may be partly you as you admit that you're not a natural at programming. If you've never done any programming before then learning programming concepts, .NET concepts and C# concepts all at the same time is undoubtedly going to be a challenge and it will be more of a challenge for some than others. Based on what you've said, I'd suggest that going back and starting again may well be a good idea, if you've got the time. It's quite possible that you have picked up some stuff along the way that you haven't even realised so things that seemed baffling the first time will now click, which makes other things click and then you may be significantly better equipped when you get back to where you are now.

One thing that can help or hinder is how you look at things. Programming doesn't exist in a vacuum and object-oriented programming particularly is based on the real world of objects that we live in. For instance, people often don't understand the concept of casting and why it's necessary so I use analogies this the following. Imagine that you're a vet and someone brings a box into your examination room. You're a vet so you know that it's an animal in the box but that's all. As a result, the only things you can do to or for that patient are things that apply to all animals. If the person then tells you that their animal is a cat then you now can reasonably do all those things that apply specifically to cats. In C# parlance, you had an Animal variable and it was cast as type Cat. Note that the object itself never changed, i.e. the cat was a cat the whole time. The term "cast" is used in the sense of "casting something in a different light", i.e. looking at the same thing in a different way. Obviously there's more to programming than just this but the more you can draw analogies to the real world, the clearer things become.

That, is a very well explained concept. I will definitely be starting the book again, and luckily with only being 17 I have some free time that I can spend on learning C#. I really enjoy when I am writing code from
a "Try it" exercise in the book, but when I am left to my own resources, I just get lost.

Thanks for the help
 
Writing pseudo code can help to avoid "getting lost", pseudo code is using your own words to plan what to code in smaller steps, steps that should be easier to translate to real code than the complete solution, and helps stay focused on programming tasks at hand. Pseudo code can be left in code as comments explaining what the code is supposed to do, both for yourself and others to read later. After explaining data type system and language structure I think most teaching systems encourage the use of pseudo code. When you're more experienced the pseudo code can be more condensed, I for example often start out with a plan in head and add types I need for objects storage and empty members where descriptive names of types, properties and methods along with comments form a framework to work out the solution.
 
Writing pseudo code can help to avoid "getting lost", pseudo code is using your own words to plan what to code in smaller steps, steps that should be easier to translate to real code than the complete solution, and helps stay focused on programming tasks at hand. Pseudo code can be left in code as comments explaining what the code is supposed to do, both for yourself and others to read later. After explaining data type system and language structure I think most teaching systems encourage the use of pseudo code. When you're more experienced the pseudo code can be more condensed, I for example often start out with a plan in head and add types I need for objects storage and empty members where descriptive names of types, properties and methods along with comments form a framework to work out the solution.

Seems like an interesting tip. I do comment out what the code means, but I forget how to actually use the concept that I commented out.

For example this is how I comment out the code:

C#:
  string myString = "This is a string."; // we say what is in our string            
            char[] separator = { ' ' }; // we are saying what a split is.
            string[] myWords;
            myWords = myString.Split(separator); // this turns the string into an array every time it seems that it has a space
            // we are also saying if you happen to meet a seprator then cut the string into arrays
            foreach (string word in myWords) // we use a loop to print it
            {
                Console.WriteLine($"{word}"); // write every individual word at each loop
            }


            Console.ReadKey();

But when I actually come to using those functions in my own code, I forget how to use it.
 
Back
Top Bottom