using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // switch = an efficient alternative to many else if statements Console.WriteLine("What day is it today?"); String day = Console.ReadLine(); switch (day) { case "Monday": Console.WriteLine("It's Monday!"); break; case "Tuesday": Console.WriteLine("It's Tuesday!"); break; case "Wednesday": Console.WriteLine("It's Wednesday!"); break; case "Thursday": Console.WriteLine("It's Thursday!"); break; case "Friday": Console.WriteLine("It's Friday!"); break; case "Saturday": Console.WriteLine("It's Saturday!"); break; case "Sunday": Console.WriteLine("It's Sunday!"); break; default: Console.WriteLine(day + " is not a day!"); break; } Console.ReadKey(); } } }
@NinetyEight4189 ай бұрын
can i use "if" or "while" in there?
@manggae6132 жыл бұрын
So concise and to the point! Love your tutorials, thank you so much :)
@michalski91413 жыл бұрын
I love how the else if example is literally yandere sim code
@leg11872 жыл бұрын
else if statements are only good if you only have a couple options to choose in your application. Otherwise, if you're like me and you're into OS Development you're going to need a TON of if statements. SO that's where case and switch come in! ;)
@Crecross Жыл бұрын
@@leg1187 You're literally saying what he has already said in the video 💀
@leg1187 Жыл бұрын
@@Crecross Yea is that a issue?
@KathushGaming Жыл бұрын
You are absolutely right Bro
@Pavme2 ай бұрын
why is that?
@DsgSleazyАй бұрын
This guy’s literally better than my 3 hour lectures, wtf😂
@juanjoseblancomurillo882611 ай бұрын
thanks, I was not quite getting it with the microsoft learn class and you help me to get it in less than 3 minutes, u r awesome
@GilGaladGaming2 жыл бұрын
bro you make so much sense I'm lucky I found you
@coolname489Ай бұрын
Lovely explanation, just startet me Apprenticeship. greetings from Germany
@bartsworkshop10 ай бұрын
Thank you for these easy to follow and short videos!
@bobojenkins580511 ай бұрын
0:57 is what you came here for
@liamf82173 ай бұрын
Thanks the video i watched previously never really explained what a switch statement is. This saved me
@owethumoyo40202 жыл бұрын
Enjoying your lesson
@kingtyphoon Жыл бұрын
This is a straight to the core and good video!
@StephenBeale4 ай бұрын
Love your work, thanks 🙏
@darkbrotherhood53632 жыл бұрын
VERY useful! Thank you!
@nkosisiya_9 ай бұрын
Common bro w
@AtillaRustemli Жыл бұрын
Thank you very much.That so helpful for me.
@TheMasterswordish2 жыл бұрын
Random comment, thanks for excisting
@jackchitte9 ай бұрын
Thank you 😊
@definitelynotchris47762 ай бұрын
my 3rd favorite kind of nintendo
@marsivanova2008 Жыл бұрын
Thanks bro! U the best!
@christianamplayo3798 Жыл бұрын
why the heck am i not subscibe to this man?!?!
@FrankIsDoingThings6 ай бұрын
Couldn’t you make a list, take user input then compare it to the list? If it’s on the list then “It’s (whatever day)” if it’s not on the list just say that’s not a day?
@hamzarafi53872 жыл бұрын
tbh else if and switch looks the same. Switch has a good presentation that's all to it.
@asadaduf Жыл бұрын
Oh it else if is the same as switch alright. But it's not the super one.
@nelliesnest5919 Жыл бұрын
The main diff is you don't need { } around every individual case, it makes the code a lot cleaner and much harder to bust up lol
3 жыл бұрын
Thanks!
@batusulun7297 Жыл бұрын
Do we use switch case only for strings? I mean after switch expression I tried to add a condition like a>60 but I got an error message. Besides in the video after the switch statement days of the weeks were written in double quote which is a string definin property.
@luckyizzac11 ай бұрын
I dont think you can put any thing other than switch related stuff inside switch blocks (you can put it inside case and default blocks), because inside the switch blocks, the code is not read line by line like an if-else branch, the algorithm inside the switch block is different
@tubetimeline10 ай бұрын
Hi batusulun, Switch can also be used with integer values. It is often used with ages for things like sorting for grade school, middle school and college.
@Hugo-Hug300026 күн бұрын
Thank you
@sickomode9966 Жыл бұрын
I’m trying to create a default for a calculator and when I add it still shows the default is there a way to correct this
@spartanranger3 жыл бұрын
Thanks for the video Bro
@atal8027 Жыл бұрын
very easily explained
@meowcat2363 Жыл бұрын
great!!!!! this type of video only work for me, short and easy to learn, i dont like other video so long and talking nonsence
@PixelPickleWaffle7 ай бұрын
Very simple
@KarimOrabi-e7b Жыл бұрын
easy simple quick
@simik48302 ай бұрын
comment for algorithmmm!!
@pawloaspaja2892 жыл бұрын
Thanks bro.
@عنيدهوقلبيطيب-ر4ك2 ай бұрын
ممكن سوال لو عايزه اكتب باستخدام case لى رقم بين 10 و 20 يكتب true يعني لو كتبت 15 يكتب. True
@whitedinamo2 жыл бұрын
lesson check😇
@alexiscoe10403 жыл бұрын
Thanks again
@Maaikus2 жыл бұрын
lovely😀
@bozhenakondrat41693 жыл бұрын
thanks :)
@nikolaivanov80072 жыл бұрын
thanks
@vinhnghiang12735 ай бұрын
Today I know that birthday is not a day!!!!
@eastern815 Жыл бұрын
👍
@The_Ancient_Guardian Жыл бұрын
come to Brazil.
@AmirmohammadKhezriGharai15 күн бұрын
❤❤
@juriappo3542 жыл бұрын
thanks Bro
@ZeeWolfed2 жыл бұрын
I don't understand what is default at the end.
@magasiku47102 жыл бұрын
It is the default thing the program writes, if the given data is none of the cases above
@ZeeWolfed2 жыл бұрын
@@magasiku4710 ah okay thanks mate
@Username92381 Жыл бұрын
It's alternative choice Bruv, you can't hower all of cases
@McPatoo Жыл бұрын
Here we go :v
@joji5577 Жыл бұрын
i love you
@budderrar57512 жыл бұрын
noice
@drea7363 Жыл бұрын
random comment 😃
@syeid_mot10 ай бұрын
لماذا الترجمة للعربية مزيفة 😡 !
@tigranziberov-mkrtchyan6375 Жыл бұрын
Console.WriteLine("please enter the names of your family members"); string names =Console.ReadLine(); switch (names) { case "Tristan": Console.Beep(); Console.WriteLine("Right,He is your son "); break; case "Artashes": Console.Beep(); Console.WriteLine("Right,he is your oldest son"); break; case "Albertina": Console.Beep(); Console.WriteLine("Right,she is your wife"); break; case "Tigran": Console.Beep(); Console.WriteLine("Right,its YOu"); break; Console.Beep(); default: Console.Beep(); Console.WriteLine("That person is not a family member"); break;
@MeilaTransFem Жыл бұрын
Actually the beep before the default shouldn't be there, it isn't connected to anything so either it will give an error or it will just never run