Found an awesome C# tutorial on YouTube-- use it to help program better in Unity3D!
Posted Jul 31, 2018, 9:32 AM UTC
Posted Jul 31, 2018, 9:32 AM UTC
Ty
Banas has tons of great vids!
In 1 video? And here I am wasting the past 5 years learning all of C# and the unity API.
"learn <put name of a programming language or framework here> in one video" my brain: "scam scam scam"^1
combined with: "use it to help program better in Unity3D" my brain: "yeah ofcourse .... scam scam scam"
jumped over the video: this video is a solid c# syntax introduction. no complains. it won't make you a c# pro, it won't make you "better" in unity.
if you know any common programming language you don't need the video at all. most parts are string operations and input/output stuff (which is absolutely fine, and you should know this stuff - imho, but) you probably don't need most of this in unity.
better suited for "becoming better in unity" would be learning programming patterns - and when to use them (this is important!).
^1 i've seen students 6+ semesters in computer science, who couldn't programm in any language (besides a bit hello world like stuff). which is sad, but fortunately programming is only one part in CS.
while i know, many here are self taught (and i taught programming myself before i went to university) this might work for many things. what you won't learn from those videos is a deeper understanding.
in the video 22:01: "we want to use the string class, this is like an object" - NO, its exactly not an object. and checking an string of emptyness in C# would be sampString == "". what he does not mention at all.
(as said i did not watch it entirely, but yeah, keep in mind that all thoose tutorials just help you so far)
When it comes to improving C# programming skills in the context of Unity, my favourite by far is u/jweimann with his Unity3D College YouTube channel. He got me hooked with his videos on SOLID principles, but he's covered so many topics that felt like wizardry for a self taught tinkerer like me, and his code reviews are brilliant. I can't recommend them enough.
and checking an string of emptyness in C# would be
sampString == "".
At my company, we exclusively use String.IsNullOrWhiteSpace(sampString), the problem is that when sampString is null, then your double equals comparison fails. Instantiating with string sampString; or string sampString = null; both will fail your test. Same goes with string sampString = " "; // a space character
So, for that reason, my company will fail your equality operator in a code review and require you use the String.IsNullOrWhiteSpace() method.
At my company, we exclusively use String.IsNullOrWhiteSpace(sampString)
which is absolutely fine! but it does more. he does not tell in his example the basic case of comparing two string contents. (the oposite, it felt like he meant to say "isNullOrEmpty" is the only correct way to do this check)
someone who had java would come and try sampString.Equals("") which is not necessary in c#.
as i said, he might go into this, in other segments, i did not watch the whole video
But the important lesson to learn is, that just seeing if it's an empty string ("") is not very valuable information. Null and whitespace are usually considered "empty" to most people as well.
The problem here is you called the guy out for using a better method to test for an "empty" string than testing for it to be equal to "" as not an ideal way to test for such a situation. When in reality, it actually is what you want more often than sampString == "". I don't blame the guy for not mentioning the equality operator there, because of how much less useful it is.
He doesn't need to explain the equality operator because people probably already know that (he went over it using ints at around the 15min mark). And if a programmer wants more information about string.IsNullOrWhiteSpace.. or even .Equals they should be going to the documentation to further their understanding. No amount of tutorials will remove your need to clarify with the documentation on occasion.
Also, wanted to point out where you said:
in the video 22:01: "we want to use the string class, this is like an object" - NO, its exactly not an object
Actually, the object he used was String, not string. One is a primitive, and one is a Type defined in mscorlib.dll and it has 8 constructor overloads, so the String object that he uses exactly is an object.
Null and whitespace are usually considered "empty" to most people as well.
but they are different things. should have shown first, the == "" then explicitly told, that strings can be null - which he does not, then telling "thats why you most often would use IsNullOrEmpty or IsNullOrWhitespace"
its not that those methods are "better" they handle more, which is not always what you want - even if it is most of the time.
he went over it using ints at around the 15min mark
but integers cant be null, would have been clever to explain that at this point.
Actually, the object he used was String, not string.
String is not an object.
stringis an alias for String in .NET. source
there is no difference between string and String.
its an type/class. an object is an instance of a type/class. thats the whole point, and he is using a static method of that class. there is the definition of the class:
namespace System
{
[ComVisible(true)]
[__DynamicallyInvokable]
[Serializable]
public sealed class String : IComparable, ICloneable, IConvertible, IEnumerable, IComparable<string>, IEnumerable<char>, IEquatable<string>
{
....
Don't confuse Types, with Type-objects (instances of the Type class)
Derek Banas has a lot of amazing videos for learning new languages and/or concepts. Definitely don't take them as a one-size-fits-all solution, they are an introductory crash course best suited for making cue card notes while watching, then you go away and research all of the main topics you wrote down in your own time.