C# enums 🪐

  Рет қаралды 78,471

Bro Code

Bro Code

Күн бұрын

Пікірлер: 81
@BroCodez
@BroCodez 3 жыл бұрын
using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // enums = special "class" that contains a set of named integer constants. // Use enums when you have values that you know will not change, // To get the integer value from an item, you must explicitly convert to an int // name = integer //Console.WriteLine(Planets.Mercury + " is planet #" + (int)Planets.Mercury); //Console.WriteLine(Planets.Pluto + " is planet #" + (int)Planets.Pluto); String name = PlanetRadius.Earth.ToString(); int radius = (int)PlanetRadius.Earth; double volume = Volume(PlanetRadius.Earth); Console.WriteLine("planet: " + name); Console.WriteLine("radius: " + radius +"km"); Console.WriteLine("volume: " + volume +"km^3"); Console.ReadKey(); } public static double Volume(PlanetRadius radius) { double volume = (4.0 / 3.0) * Math.PI * Math.Pow((int)radius, 3); return volume; } } enum Planets { Mercury = 1, Venus = 2, Earth = 3, Mars = 4, Jupiter = 5, Saturn = 6, Uranus = 7, Neptune = 8, Pluto = 9 } enum PlanetRadius { Mercury = 2439, Venus = 6051, Earth = 6371, Mars = 3389, Jupiter = 69911, Saturn = 58232, Uranus = 25362, Neptune = 24622, Pluto = 1188 } }
@girlkun7518
@girlkun7518 3 жыл бұрын
Hi! Could you make a video about topic "How to handle 2 keys pressed simultaneously in java"? Please... I'm Vietnamese and I'm really looking forward to this
@Wojbest_YT
@Wojbest_YT 11 ай бұрын
nerds about to be like " 🤓um actually Pluto isn't a planet🤓"
@whatdawhatgaming
@whatdawhatgaming 2 жыл бұрын
This is the best explanation of an enum I've come across. I knew exactly what is ACTUALLY was within the first 20 seconds. "A special type of class that contains a set of named integer constants." Literally a perfect explanation for me.
@mttzern5457
@mttzern5457 2 жыл бұрын
Hands down the best c# explanations there is in regards to value for time spent - much appreciated!!
@NotTheHeroStudios
@NotTheHeroStudios 2 жыл бұрын
I got so hyped when you put Pluto on that list.
@jamiebertrand2669
@jamiebertrand2669 3 жыл бұрын
This helped a lot! I learned more in your 7 minute video than a 2 hour lecture!
@Iz_moe
@Iz_moe 3 жыл бұрын
"Pluto is a planet" -Jerry Smith
@BroCodez
@BroCodez 3 жыл бұрын
Pluto is a planet
@user-or6mz4gy6i
@user-or6mz4gy6i 10 ай бұрын
I really loved how you casually listed the planets radius. I don't know if it was really from memory but if it was you deserve other props here in addition to your programming skill. By the way, are Enums a special type of class or struct. They felt closer to the second to me. Thanks!
@user-or6mz4gy6i
@user-or6mz4gy6i 10 ай бұрын
I have my answer. As structs, enums are value types and stored in the stack. They they feel closer to structs. But if you change "special type of class" by "special type of data structure" it is still valid. Thanks!
@gameprogramming6550
@gameprogramming6550 Жыл бұрын
I have watched your almost all c# videos playlist. Thanks for the great content !!
@rolfvanderbijl
@rolfvanderbijl 2 жыл бұрын
Great tutorial, clear, good examples and me is finally understanding why what I wanted to try didn't work. Thanks a lot!
@nav3622
@nav3622 2 жыл бұрын
I love you. You have helped me study for my midterms. I hope you get lots of happiness and success.
@ranjanadissanayaka5390
@ranjanadissanayaka5390 10 ай бұрын
I was really curious about Enum. Thanks for the video Sir. 😀
@atan6730
@atan6730 3 жыл бұрын
Pluto is not a planet, ruined my immersion.... Nice explaining of ENUMs btw, keep up the good work ^^
@SoDamnMetal
@SoDamnMetal 2 жыл бұрын
Oh you're one of "those" guys huh? 🙄
@mysteriousmop7686
@mysteriousmop7686 Жыл бұрын
if (joke) { return funny; } else { return !funny; }
@snahhhhhhh
@snahhhhhhh Жыл бұрын
@@mysteriousmop7686”funny”
@tymofii4718
@tymofii4718 2 жыл бұрын
Amazing Explanation and super quick. Didnt need to speed it up like most tutorials
@deepbule3517
@deepbule3517 2 жыл бұрын
very clear and helpful. Thank you!
@MoHaTa-u3f
@MoHaTa-u3f 3 ай бұрын
So basically "emun" is really good for values that have a name, like measurements for example. You could make a measurements enum with "foot = 12", and you could use either Measurements.foot; to state the name "foot", or do (int)Measurements.foot; to get the value of foot, which is 12
@spartanranger
@spartanranger 3 жыл бұрын
Thanks for the video Bro.
@McPatoo
@McPatoo Жыл бұрын
Helpful as always :) gigachad bro
@ozknowledge4159
@ozknowledge4159 3 жыл бұрын
superbe Thank you for this great tutorial
@erikseberozvoj
@erikseberozvoj 2 жыл бұрын
Great video bro! keep it up
@curtislee1485
@curtislee1485 4 ай бұрын
You are also able to change the underlying data type used to store the values in an enum. ie change to use a byte, float, double etc. enum AnEnumUsingFloats : byte { SomeValue = 100, AnotherValue = 244 } Just remember to cast to the correct data type when you need to access the value.
@eerice704
@eerice704 Жыл бұрын
Justice for Pluto ✊🫡
@Bear-nr9jo
@Bear-nr9jo 3 жыл бұрын
Bro your channel is lit my guy
@timoneri8812
@timoneri8812 2 жыл бұрын
📡👽🛸 Thank you! Very Clear! ;)
@boyar3033
@boyar3033 Жыл бұрын
My go to man for c#
@harmony4537
@harmony4537 2 жыл бұрын
you are the best
@zachdavis6624
@zachdavis6624 3 жыл бұрын
This was helpful! thanks.
@chrisp2639
@chrisp2639 2 жыл бұрын
good stuff
@titkosaaron4067
@titkosaaron4067 3 жыл бұрын
Great video, thanks!
@w9xv_433
@w9xv_433 Жыл бұрын
🐐fr
@TIPSFIN
@TIPSFIN 2 жыл бұрын
i have a question. If i remove the points and zeroes before the number 4 and number 3 in my method, why does it fuck up my answer? This works: public static double CalculateBallVolume(double aRadius) { double volume = (4.0 / 3.0) * Math.PI * Math.Pow(aRadius,3); return volume; } This gives me a different answer that is not the volume of a sphere: public static double CalculateBallVolume(double aRadius) { double volume = (4 / 3) * Math.PI * Math.Pow(aRadius,3); return volume; } You can try it out yourself. (4.0 / 3.0) and (4 / 3) give different answers for some reason.
@ajlakanen
@ajlakanen 11 ай бұрын
When both of the numbers are integers, the result will also be an integer. When at least one of the numbers is a double, the result will be double. Technically that's something called "operator overloading" -- that is, the division operator works a bit differently based on the types of the operands.
@Commenter339
@Commenter339 Жыл бұрын
great vid
@zachnewby4739
@zachnewby4739 Жыл бұрын
If you are having trouble, enums can't be member variables, meaning they can't go inside other classes.
@LegendIke
@LegendIke 2 күн бұрын
thanks king
@fredrikandersson1538
@fredrikandersson1538 6 ай бұрын
Solid ty
@amplifiedge
@amplifiedge Жыл бұрын
thank you bro!
@asapboy1895
@asapboy1895 3 жыл бұрын
This can be ran in java right? (Nice Work btw Bro)
@ag4-z4z
@ag4-z4z Жыл бұрын
Thanks bro
@linglingzhang8583
@linglingzhang8583 3 жыл бұрын
i really like the way how you teach, if you are familiar with java framework, and make a tutorial for that, that will be great.!
@welitonkira2830
@welitonkira2830 2 жыл бұрын
Thank you!
@Cheboksarov
@Cheboksarov 2 жыл бұрын
Познавательно.
3 жыл бұрын
Thanks Bro!
@nguyencanh8369
@nguyencanh8369 2 жыл бұрын
thanks
@giacomorinaldi
@giacomorinaldi 2 жыл бұрын
hello Bro, i have one question: why you wrote in this way the method ? public static double Volume(PlanetRadius anyvariable) { double volume = (4.0 / 3.0) * Math.PI * Math.Pow((int)anyvariable, 3); return volume; } i dont understand why you put PlanetRadius in the method. please could you help me ?
@jessiebessie3616
@jessiebessie3616 Жыл бұрын
So can we use Planet enum to fetch corresponding values in Planetradius enum directly?
@AliTahreiSh
@AliTahreiSh 2 жыл бұрын
What is the difference between Enum and Dictionary?
@emilyalbert3366
@emilyalbert3366 Жыл бұрын
you can update, add, and change values in a dictionary
@plebaroni3495
@plebaroni3495 4 ай бұрын
YEEEESSSS PLUTO LETS FUCKING GOOO!!!
@xwoken
@xwoken 3 жыл бұрын
nice
@fruitfunfitness3584
@fruitfunfitness3584 2 жыл бұрын
I was surprised that your double ended up with a non integer value when it was calculated with an int, without casting the int into double. I suppose Math.pow is casting it.
@triodit
@triodit 2 жыл бұрын
if pluto is a planet, then there are over 30,000 planets in the solar system....
@zachdavis6624
@zachdavis6624 3 жыл бұрын
I was a little confused by the way you passed in radius there at the end, but that might just be my inexperience in C#
@satyamshankar5459
@satyamshankar5459 3 жыл бұрын
great!
@marajruno
@marajruno 3 ай бұрын
"Pluto is a planet" sounded like Jerry Smith 😀
@DetCoAnimeFan
@DetCoAnimeFan 3 жыл бұрын
Java and C# enums are so much similar that it is confusing me.
@dakar_84
@dakar_84 3 жыл бұрын
C# really similar to Java itself
@abdurahmon9926
@abdurahmon9926 Жыл бұрын
real gigachad
@nulzn8691
@nulzn8691 2 жыл бұрын
I though it was going to be a bigger debate about whether Pluto is a planet or not 😅
@Lonchanick
@Lonchanick Жыл бұрын
I find barely useful the enums utility ... that could be done with a class right?
@davidtummers8310
@davidtummers8310 11 ай бұрын
WROOOOOONG! Pluto isn't a Planet anymore (sadly😢)
@whitedinamo
@whitedinamo 3 жыл бұрын
lesson check😇
@kvelez
@kvelez Жыл бұрын
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { public class Program { static void Main(string[] args) { Console.WriteLine($"{Planets.Pluto} is the #{(int)Planets.Pluto}"); Console.WriteLine($"{(int)Radius.Uranus}"); } } enum Planets { Mercury = 1, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Nepture, Pluto, } enum Radius { Mercury = 1453, Venus = 56443, Earth = 363, Mars = 7463, Jupiter = 64532, Saturn = 3442, Uranus = 35442, Nepture = 76393, Pluto = 32408, } }
@definitelynotchris4776
@definitelynotchris4776 4 ай бұрын
Pluto is a planet
@tedjames2731
@tedjames2731 2 ай бұрын
Succinct!
@aditya_asundi
@aditya_asundi 3 жыл бұрын
first
@lotar1228
@lotar1228 Жыл бұрын
i know that i shouldn't be focusing on this but pluto is not a planet
@SpecsNStats
@SpecsNStats 2 жыл бұрын
a random comment
@shaikhparwez7276
@shaikhparwez7276 11 ай бұрын
why u have pluto in there UNSUBSCRIBED !
@triton5457
@triton5457 2 жыл бұрын
salad 🥗
@William-nani
@William-nani 16 күн бұрын
enums SUCK
@mahdialaaaldine
@mahdialaaaldine Жыл бұрын
Thank you !
@viniciuslima1064
@viniciuslima1064 2 ай бұрын
Thanks bro
C# generics ⁉️
5:33
Bro Code
Рет қаралды 84 М.
Жездуха 41-серия
36:26
Million Show
Рет қаралды 5 МЛН
Жездуха 42-серия
29:26
Million Show
Рет қаралды 2,6 МЛН
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
C# multithreading 🧶
6:59
Bro Code
Рет қаралды 170 М.
C# objects 🧍‍♂️
5:01
Bro Code
Рет қаралды 56 М.
Master Design Patterns & SOLID Principles in C# - Full OOP Course for Beginners
11:46:54
What are Events? (C# Basics)
15:05
Code Monkey
Рет қаралды 411 М.
C# methods 📞
6:05
Bro Code
Рет қаралды 67 М.
C# Lists 📃
6:46
Bro Code
Рет қаралды 115 М.
C# polymorphism 🎭
5:11
Bro Code
Рет қаралды 92 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 228 М.
C# static 🚫
5:03
Bro Code
Рет қаралды 84 М.
Do YOU Understand WHAT JUST HAPPENED!? 😂 #shorts
0:57
LankyBox World
Рет қаралды 1,6 МЛН
Самые простые строительные леса
0:54
Канал ИДЕЙ
Рет қаралды 1 МЛН
Что такое дагестанский кирпичный завод!
0:53
АВТОБРОДЯГИ - ПУТЕШЕСТВИЯ НА МАШИНЕ
Рет қаралды 746 М.
изобрёл молоток мечты
0:55
Упоротый ПОВАР
Рет қаралды 543 М.
КОРОЧЕ ГОВОРЯ, НЕДЕЛЯ БЕЗ ТЕЛЕФОНА
3:54