C# Tutorial 3 Conditionals While Exceptions

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024

ความคิดเห็น • 160

  • @ramsyrama
    @ramsyrama 7 ปีที่แล้ว +33

    The best programming channel of all times.... If Derek Banas changed my life from a little village in Africa.. He can do it too for you😀

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +2

      Thank you for your kind compliment :) I'm very happy I was able to help.

    • @mudzibaba
      @mudzibaba 5 ปีที่แล้ว +3

      I need African programmer and I was wondering if you can cast voodoo on this girl I like to fall in love with me?

    • @ramsyrama
      @ramsyrama 3 ปีที่แล้ว

      @Danyell Nachman don't be evil

    • @ramsyrama
      @ramsyrama 3 ปีที่แล้ว

      @Jasper Morgan stop spamming

  • @philmageo
    @philmageo 4 ปีที่แล้ว +1

    I expecially loved the part on exception handling which comes well after the Convert part ! Thank you for this so consise and useful video

  • @larssonk22
    @larssonk22 7 ปีที่แล้ว +9

    Oh wow you're churning these out quick. Much appreciated!

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +10

      I'm doing my best. The next one will be up on Wednesday

  • @abhinavjha3082
    @abhinavjha3082 6 ปีที่แล้ว +4

    Love his tutorials and the way he says 'Aaaannndd!'(and)

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว +1

      That's funny :) Thank you

  • @spencerwhc
    @spencerwhc 3 ปีที่แล้ว

    Thank you so much for this quick but informative video! I struggle a lot in learning C# and your video make it so much easier for me to learn !!!!! You are amazing and thanks again !!!!

  • @masoudehsani7460
    @masoudehsani7460 7 ปีที่แล้ว

    Hi Derek, the way you teach is straightforward and awesome even for experienced developers like me. I subscribed you and started to review all my knowledge by help of your fantastic videos. Thanks a lot and best wishes for you.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you for the nice compliment :)

  • @Gabriel-yk4it
    @Gabriel-yk4it 3 ปีที่แล้ว +1

    finally a tutorial with which i can transition from c++ to c#

  • @discipleanele9297
    @discipleanele9297 3 ปีที่แล้ว

    Am still here. Enjoying learning

  • @sean893
    @sean893 6 ปีที่แล้ว +1

    Derek, just want to ask a question in 3:30
    Console.WriteLine("! true = " + (!true));
    *Output: ! true = False* //because the ! symbol is put in front of the (true)
    Console.WriteLine(!false);
    *Output: True*
    Console.WriteLine(false);
    *Output: false*
    Console.WriteLine(true);
    *Output: True*
    Did I get it correct?

  • @8koi139
    @8koi139 2 ปีที่แล้ว

    Some important tips is that, never use catch(Exception) because will prevent your program from closing if you try to stop it by command/keyboard.
    It's a pretty specific had to detect error, and those are the worst lol

  • @jabbalaci8931
    @jabbalaci8931 7 ปีที่แล้ว

    Thanks a lot for this series. I'm doing it under Linux with Visual Studio Code, compiling with "dotnet run". Works well :) I heard a lot of good things of this language, so finally I decided to try it. Your videos help a lot.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you for watching it :) I'm happy it is helping

  • @fsacer
    @fsacer 7 ปีที่แล้ว +2

    It won't skip the code at 7:30, code under label OtherSchool will be executed for any case in switch statement.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Sorry for not explaining that better

  • @MyGreenpotato
    @MyGreenpotato 4 ปีที่แล้ว

    First video from you aaaaannnnd I immediately searched about you on udemy. I hope you will a release a c# course there. You know why? Because you are a unique teacher who diserves a lot. Thanks

    • @derekbanas
      @derekbanas  4 ปีที่แล้ว +2

      Thank you for the nice compliment :) I plan on sticking with Python this year on Udemy. I want to make sure everyone that supported me gets about 250 videos to show how much I appreciate them

  • @Layarion
    @Layarion 6 ปีที่แล้ว +1

    Question: While Loops
    Can I create a while loop that is just:
    While(true)
    {
    //do stuff
    if(exit is typed)
    WhileCondition = False
    }
    Now I'm not asking if I can change a variable to false, I mean literally, put true in the while condition, and directly change the While loops condition to false?

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว

      You could use while like that, but try using break instead with a condition to jump out of the loop

    • @Layarion
      @Layarion 6 ปีที่แล้ว

      the silly thing is, i already figured that out, but forgot that i figured that out while watching the video.

  • @ProjectInitiative
    @ProjectInitiative 7 ปีที่แล้ว

    Really enjoyed the exception handling and the convert function, they were of platinum quality! 😉

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +1

      Thank you very much :) That's funny

  • @ALL_ONE_SUN
    @ALL_ONE_SUN 7 ปีที่แล้ว +5

    Think it's obvious now...somebody likes C#...well...thankfully it helps Me to use Unity better. Thanks!

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +13

      I can't wait to start making Unity tutorials

  • @andrewcook1428
    @andrewcook1428 7 ปีที่แล้ว +1

    so for the random number command if I want to generate numbers 1 through 3 do I use
    Random p1 = new Random();
    int c1 = p1.Next(1, 3);

    • @94D33M
      @94D33M 5 ปีที่แล้ว

      The 1 is inclusive, and the 3 is EXCLUSIVE , so your c1 will contain only between 1 and 2

  • @luansalja60
    @luansalja60 7 ปีที่แล้ว

    max respect for Derek, another great tutorial !!!

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you :) I do my best

  • @markmoore869
    @markmoore869 2 ปีที่แล้ว

    Hi Derek, these are really great tutorials, can I just say that at about 7:30 your Goto statement is not skipped and always processed regardless of what Age is set to ... (I'm a C programmer learning C#).

    • @derekbanas
      @derekbanas  2 ปีที่แล้ว

      Whoops sorry if there was an error. I'll be making an updated C# video with Maui in the next couple of weeks

    • @markmoore869
      @markmoore869 2 ปีที่แล้ว

      @@derekbanas No problem, I'm really enjoying the videos and would recommend them to anyone wanting to learn C#

  • @alpsavasdev
    @alpsavasdev 7 ปีที่แล้ว

    quick and smooth, as always. from Derek! even if I know these stuff, it is always awesome to hear from you too!
    please cover some advanced topics of C# as well! :)

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you for the nice compliment :) I definitely will cover complex stuff soon

  • @raegune
    @raegune 7 ปีที่แล้ว

    The Relational Operators song at 0:42 I feel could be used as material for a kids series on programming hahaha.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +1

      +Graham Regan that's funny 😂

    • @raegune
      @raegune 7 ปีที่แล้ว

      C# Sesame Street 😂

  • @neverlash
    @neverlash 7 ปีที่แล้ว +2

    Hi, great video. Why do you use the finally block? Isn't the same thing just using the WriteLine alone?

  • @CHBY
    @CHBY 5 ปีที่แล้ว

    I'm really liking C# compared to other languages...I'm all in with C#, .NET and SQL

  • @amirhosseinnateghi2120
    @amirhosseinnateghi2120 6 ปีที่แล้ว

    Hi Everyone,
    Thank you Derek for this fabulous C# source. I would like to learn how to work with form application like creating a calculator. I am not sure which of your videos is appropriate to address it. Could anyone let me know which tutorial part should I watch?
    Thank you again.

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว

      I'm happy you liked it :) I make a calculator here th-cam.com/video/G-BRSwClK_4/w-d-xo.html

  • @publicstaticvoid3224
    @publicstaticvoid3224 7 ปีที่แล้ว +1

    Question: the "Finally" block, is that considered like the default "try/catch" ?

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Not really because it is always called

  • @Zeay
    @Zeay 7 ปีที่แล้ว

    Love C# and love your channel!
    Are you going to cover any kind of networking and database connections?

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +1

      Thank you :) Yes most definitely

  • @pedrobeja1901
    @pedrobeja1901 7 ปีที่แล้ว

    Great as always! Thanks! :)
    BTW I'm very excited to know that you are planning on doing a Unity series!

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +4

      Thank you :) As soon as I finish up with C# basics I'll move into making apps with Xamarin and then Unity

    • @pedrobeja1901
      @pedrobeja1901 7 ปีที่แล้ว +1

      That's awesome! Looking forward to it. Keep it up bro!

  • @jaypatel9316
    @jaypatel9316 3 ปีที่แล้ว

    Thanks Derek, I had a question, Why you have incremented 2 time i like i++ in a while loop? one in if condition and another at last:

  • @359WiseGuy
    @359WiseGuy 6 ปีที่แล้ว

    Excellent! Thank your, Mr.Banas :)

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว +1

      I'm very happy to be of help :)

  • @marh122
    @marh122 7 ปีที่แล้ว

    Hi Derek, your doing best videos I learned a lot from them. I have such question - is it possible to go even deeper to present some kind of mathematical examples ? E.g. using matrixes for the purpose of programming, some kind of functions (I mean math functions), equations, etc. ?
    Because I value myself as lower class programmer and I couldnt pass math exams because I didnt see any purpose of matrixes because even teachers cannot explain you how it works in real life.
    My former class mate is programmer but doing 3D modeling via matrixes, math function, which I cannot do because I dont understand those things.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +1

      I'll need to do a lot of math once I start covering how to make games. As you said though I'll have to get into 3D before I can properly cover the use for matrixes and such. This whole year will be dedicated to games and I'll get there eventually. Sorry for the wait

    • @marh122
      @marh122 7 ปีที่แล้ว

      Dont apologize, you are doing great job ! :) and I cannot wait until I learn those things :)

  • @hansrajrami
    @hansrajrami 7 ปีที่แล้ว

    when i make random no game
    the code is here
    Random rand = new Random();
    int SecretNum = rand.Next(1, 11);
    int GuessedNum = 0;
    do
    {
    Console.WriteLine(SecretNum);
    Console.Write("enter number between 1 & 10 : ");
    GuessedNum = Convert.ToInt32(Console.ReadLine());
    } while (SecretNum != GuessedNum);
    the message popped that
    format exception was unhandledAn unhandled
    exception of type 'System.FormatException' occurred in mscorlib.dll
    Additional information: Input string was not in a correct format.

  • @peracc8862
    @peracc8862 7 ปีที่แล้ว +3

    Can you do Cocos# for cross platform game development after this? It would make sense if you plan on doing Xamarin too

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Yes I'll be covering both

  • @machiavelidx7269
    @machiavelidx7269 6 ปีที่แล้ว

    Derek, What is the difference between
    StringComparison.Ordinal
    and
    StringComparison.OrdinalIgnoreCase.

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว +1

      The second ignores the case meaning a and A are the same

    • @machiavelidx7269
      @machiavelidx7269 6 ปีที่แล้ว

      Platinum!

  • @SandunilJayasinghe
    @SandunilJayasinghe 7 ปีที่แล้ว

    Hey Derek! Appreciating your hard work as always, Will you be doing a tutorial on JavaCC anytime soon?

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you :) Sorry, but I'll be focusing on C#, cross platform apps and game for a while

  • @maazshaikh2953
    @maazshaikh2953 7 ปีที่แล้ว +1

    how to create a case with multiple value?
    it will be tiring to put a case for every value

  • @joshuacoker9482
    @joshuacoker9482 7 ปีที่แล้ว +1

    Hi, I just have a simple question, is there a reason that you would use:
    if (name.Equals(name2, StringComparison.Ordinal))
    instead of:
    if (name == name2)
    Thanks.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      In Java this is a big no no, but you are indeed correct that either will work in C# as long as both are strings

    • @joshuacoker9482
      @joshuacoker9482 7 ปีที่แล้ว

      OK thanks!

  • @skylarkenneth3784
    @skylarkenneth3784 5 ปีที่แล้ว +2

    x2 speed is out of this world

  • @jemschaudhary5922
    @jemschaudhary5922 4 ปีที่แล้ว

    I watched some of your C# tutorials and found out that you are always using static functions. Whats the reason behind that?
    Why its not private or public?

    • @derekbanas
      @derekbanas  4 ปีที่แล้ว +1

      A static function is a function that belongs to the class. It is a utility function. Basically if it doesn’t represent a real world thing that that object would do I make it static.

    • @jemschaudhary5922
      @jemschaudhary5922 4 ปีที่แล้ว

      @@derekbanas okay. Thanks for explaination.

  • @elchureee
    @elchureee 5 ปีที่แล้ว

    Great Tutorial!! Love the way you teach!
    Derek, when you try to divide by zero, if you dont "throw" the exception, the system won't throw it automatically for you?
    Thanks!

    • @derekbanas
      @derekbanas  5 ปีที่แล้ว

      Thank you :) Some languages think dividing by zero is ok

  • @codergirl1518
    @codergirl1518 7 ปีที่แล้ว +1

    Hey Derek you might not believe this but I was going to ask you if you could make a tut on "Exception Handling"...too scary man! :

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      I'll be doing more with Exception Handling. This was just the first taste

  • @Samar-pro
    @Samar-pro 7 ปีที่แล้ว

    make a video showing: how to prove or express that you are extraordinary man for a job. all the thing to avoid and all the thing to attain in the process form sending someone you CV (resume) to the Job interview.
    I AM WAITING...

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Sales skills will help you get a job better then anything else and I have a sales tutorial here th-cam.com/play/PL61952EC6E585D073.html

  • @austinwhite9225
    @austinwhite9225 7 ปีที่แล้ว

    i didn't watch the video yet just wanted to let you've earned my subscription on patreon for your great content and quick reply. :)

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you very much :) I greatly appreciate that.

  • @h1p9y56
    @h1p9y56 7 ปีที่แล้ว +1

    Platinum
    (It is a shame there aren't more of these comments)

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you :) Yes it is very sad that almost nobody watches the whole video :( I keep trying to make tutorials that keep people engaged, but I'm not sure if there is really any way to achieve much over a 15% retention

    • @h1p9y56
      @h1p9y56 7 ปีที่แล้ว

      I'd say that a lot of people who are starting out programming take online courses these days, even though you can get the same information for free. I very much appreciate people who take the time to make these sorts of videos, so thank you.

    • @94D33M
      @94D33M 5 ปีที่แล้ว

      What Platinum?

  • @lsironic
    @lsironic 5 ปีที่แล้ว

    Great tutorial, thanks Derek.
    Range switch statement is now available in C# using when keyword.
    docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/switch
    sample:
    int num = 129;
    switch (num)
    {
    case int n when (n < 50):
    Console.WriteLine($"{n} is less than 50");
    break;
    case int n when (n = 50):
    Console.WriteLine($"{n} is beetween 50 and 100: {n}");
    break;
    case int n when (n > 100):
    Console.WriteLine($"{n} is greather than 100");
    break;
    }

    • @derekbanas
      @derekbanas  5 ปีที่แล้ว

      Thank you for sharing :)

  • @linuxisstillthebest6863
    @linuxisstillthebest6863 7 ปีที่แล้ว

    Hello Mr. Banas. I was wondering, if you covered pyaudio? Because apparently, that is the only thing, which works on my windows 7, without showing an annoying media player pop up. (I'm trying to make an AI)

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Sorry, but I didn't cover it

    • @linuxisstillthebest6863
      @linuxisstillthebest6863 7 ปีที่แล้ว

      It's okay. I gave up that idea. I'm not sure, what I am going todo, I did a kik auto loggin but bluestacks bugs around. I'm idea less. Except I can figure out how to auto loggin to wifi on a raspberry pi

    • @linuxisstillthebest6863
      @linuxisstillthebest6863 7 ปีที่แล้ว

      Hi!
      I was wondering, If I could convert all these lines in just one or 5. I want to do a input thing, like if I sa "Hello", it responds and says with a audio file "Hello"
      import pyaudio
      import wave
      chunk = 1024
      wf = wave.open('C:\\Users\COMPUTER_NAME\Desktop/test.wav', 'rb')
      p = pyaudio.PyAudio()
      stream = p.open(
      format=p.get_format_from_width (wf.getsampwidth ()) ,
      channels=wf.getnchannels () ,
      rate=wf.getframerate () ,
      output=True)
      data = wf.readframes(chunk)
      while data != '':
      stream.write(data)
      data = wf.readframes(chunk)
      stream.close()
      p.terminate()

  • @SunnyApples
    @SunnyApples 7 ปีที่แล้ว

    Thank you for the video!

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      You're very welcome :)

  • @RaySG
    @RaySG 7 ปีที่แล้ว

    Like the c# tutorials!! but when i code a game on unity its different then normal c#.net coding. why is that? (print instead of Console.WriteLine)

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +1

      Thank you :) I'll cover all of the differences soon

  • @applejack77778
    @applejack77778 7 ปีที่แล้ว

    Platinum! Wow, I must've been psychic when I said platinum last video.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you for doing that :)

  • @draakisback
    @draakisback 7 ปีที่แล้ว

    nice tutorial as always.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you very much :)

  • @2005Azm
    @2005Azm 7 ปีที่แล้ว

    Thank you sir !

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      You're very welcome :)

  • @pbmzbr
    @pbmzbr 6 ปีที่แล้ว +2

    I don't know if someone notice that, but:
    else if ((age > 7) && (age < 13))
    else if ((age > 13) && (age < 19))
    So, if my student have '13' || >=19 age, then he go to college. :D

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว

      Sorry about the typo :)

  • @wumbology8421
    @wumbology8421 7 ปีที่แล้ว

    Will you be doing a postgres tutorial?

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      I'm working on it

  • @2271masoud
    @2271masoud 7 ปีที่แล้ว

    Awesome
    Thanks

  • @zmOe1
    @zmOe1 7 ปีที่แล้ว

    thank you

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      I'm happy to help :)

  • @turnen69
    @turnen69 7 ปีที่แล้ว

    Can you make a serie on WPF programming? in c#

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      YEs that is coming

    • @turnen69
      @turnen69 7 ปีที่แล้ว

      Derek Banas amazing! You're actually the only one that provides such informative guides on programming that come with great examples. Many youtubers can learn from you! When are you planning to cover threading and inheritance?

  • @GilbertoCAcanal
    @GilbertoCAcanal 7 ปีที่แล้ว +5

    Re,re, this guy don't breathe!

  • @Sunohn
    @Sunohn 7 ปีที่แล้ว

    Platinum.
    I was wondering if the continue operator is the same as the return operator in Python.

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Continue works the same as Continue in Python works. It skips the rest of the loop and jumps back to the beginning of the loop. Return is used to return from a function

  • @ysnkanakro2361
    @ysnkanakro2361 7 ปีที่แล้ว +1

    thank you very much (y)

  • @arandomguyontheinternet3839
    @arandomguyontheinternet3839 6 ปีที่แล้ว

    wouldn't the first code cause kids less than 5 years of age being sent to college?

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว

      Sorry about the typo

  • @redbeardhomes
    @redbeardhomes 6 ปีที่แล้ว

    You sound a lot like Sal from Khan Academy

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว +2

      Thank you for the compliment :) He was the reason I started making videos.

  • @aliasgharTofighian
    @aliasgharTofighian 7 ปีที่แล้ว

    The one who disliked it, please, please tell me you are a programmer not a hater !

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +1

      I don't worry about the dislikes. It is normally someone that wanted me to cover a different topic

  • @outlawww4209
    @outlawww4209 7 ปีที่แล้ว

    Derek you play games?

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Yes I love games. I just got a PS4 and love it!!!

  • @codergirl1518
    @codergirl1518 7 ปีที่แล้ว +1

    By the way..."Platinum"...!

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you for doing that :)

  • @ellena1903
    @ellena1903 7 ปีที่แล้ว

    Platinum!

  • @krasorx
    @krasorx 7 ปีที่แล้ว

    Star Platinum!

  • @DrAlbinoMouse
    @DrAlbinoMouse 3 ปีที่แล้ว +1

    age = 13;
    "go to college"

  • @bartonpaullevenson3427
    @bartonpaullevenson3427 6 ปีที่แล้ว

    Try age 13

  • @karolisrazmus5819
    @karolisrazmus5819 7 ปีที่แล้ว

    Platinum

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      Thank you for watching the whole video :)

  • @mrmlgtech1568
    @mrmlgtech1568 7 ปีที่แล้ว +1

    hello

  • @jimbeammeup9879
    @jimbeammeup9879 5 ปีที่แล้ว

    Kindergarten? Didn‘t know that it actually means the same like in german lol

    • @derekbanas
      @derekbanas  5 ปีที่แล้ว +1

      Yes we stole that name from Germany

  • @outlawww4209
    @outlawww4209 7 ปีที่แล้ว

    video games

  • @Alphabet_-_
    @Alphabet_-_ 5 ปีที่แล้ว