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 } }
@girlkun75183 жыл бұрын
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_YT11 ай бұрын
nerds about to be like " 🤓um actually Pluto isn't a planet🤓"
@whatdawhatgaming2 жыл бұрын
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.
@mttzern54572 жыл бұрын
Hands down the best c# explanations there is in regards to value for time spent - much appreciated!!
@NotTheHeroStudios2 жыл бұрын
I got so hyped when you put Pluto on that list.
@jamiebertrand26693 жыл бұрын
This helped a lot! I learned more in your 7 minute video than a 2 hour lecture!
@Iz_moe3 жыл бұрын
"Pluto is a planet" -Jerry Smith
@BroCodez3 жыл бұрын
Pluto is a planet
@user-or6mz4gy6i10 ай бұрын
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-or6mz4gy6i10 ай бұрын
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 Жыл бұрын
I have watched your almost all c# videos playlist. Thanks for the great content !!
@rolfvanderbijl2 жыл бұрын
Great tutorial, clear, good examples and me is finally understanding why what I wanted to try didn't work. Thanks a lot!
@nav36222 жыл бұрын
I love you. You have helped me study for my midterms. I hope you get lots of happiness and success.
@ranjanadissanayaka539010 ай бұрын
I was really curious about Enum. Thanks for the video Sir. 😀
@atan67303 жыл бұрын
Pluto is not a planet, ruined my immersion.... Nice explaining of ENUMs btw, keep up the good work ^^
Amazing Explanation and super quick. Didnt need to speed it up like most tutorials
@deepbule35172 жыл бұрын
very clear and helpful. Thank you!
@MoHaTa-u3f3 ай бұрын
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
@spartanranger3 жыл бұрын
Thanks for the video Bro.
@McPatoo Жыл бұрын
Helpful as always :) gigachad bro
@ozknowledge41593 жыл бұрын
superbe Thank you for this great tutorial
@erikseberozvoj2 жыл бұрын
Great video bro! keep it up
@curtislee14854 ай бұрын
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 Жыл бұрын
Justice for Pluto ✊🫡
@Bear-nr9jo3 жыл бұрын
Bro your channel is lit my guy
@timoneri88122 жыл бұрын
📡👽🛸 Thank you! Very Clear! ;)
@boyar3033 Жыл бұрын
My go to man for c#
@harmony45372 жыл бұрын
you are the best
@zachdavis66243 жыл бұрын
This was helpful! thanks.
@chrisp26392 жыл бұрын
good stuff
@titkosaaron40673 жыл бұрын
Great video, thanks!
@w9xv_433 Жыл бұрын
🐐fr
@TIPSFIN2 жыл бұрын
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.
@ajlakanen11 ай бұрын
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 Жыл бұрын
great vid
@zachnewby4739 Жыл бұрын
If you are having trouble, enums can't be member variables, meaning they can't go inside other classes.
@LegendIke2 күн бұрын
thanks king
@fredrikandersson15386 ай бұрын
Solid ty
@amplifiedge Жыл бұрын
thank you bro!
@asapboy18953 жыл бұрын
This can be ran in java right? (Nice Work btw Bro)
@ag4-z4z Жыл бұрын
Thanks bro
@linglingzhang85833 жыл бұрын
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.!
@welitonkira28302 жыл бұрын
Thank you!
@Cheboksarov2 жыл бұрын
Познавательно.
3 жыл бұрын
Thanks Bro!
@nguyencanh83692 жыл бұрын
thanks
@giacomorinaldi2 жыл бұрын
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 Жыл бұрын
So can we use Planet enum to fetch corresponding values in Planetradius enum directly?
@AliTahreiSh2 жыл бұрын
What is the difference between Enum and Dictionary?
@emilyalbert3366 Жыл бұрын
you can update, add, and change values in a dictionary
@plebaroni34954 ай бұрын
YEEEESSSS PLUTO LETS FUCKING GOOO!!!
@xwoken3 жыл бұрын
nice
@fruitfunfitness35842 жыл бұрын
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.
@triodit2 жыл бұрын
if pluto is a planet, then there are over 30,000 planets in the solar system....
@zachdavis66243 жыл бұрын
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#
@satyamshankar54593 жыл бұрын
great!
@marajruno3 ай бұрын
"Pluto is a planet" sounded like Jerry Smith 😀
@DetCoAnimeFan3 жыл бұрын
Java and C# enums are so much similar that it is confusing me.
@dakar_843 жыл бұрын
C# really similar to Java itself
@abdurahmon9926 Жыл бұрын
real gigachad
@nulzn86912 жыл бұрын
I though it was going to be a bigger debate about whether Pluto is a planet or not 😅
@Lonchanick Жыл бұрын
I find barely useful the enums utility ... that could be done with a class right?
@davidtummers831011 ай бұрын
WROOOOOONG! Pluto isn't a Planet anymore (sadly😢)
@whitedinamo3 жыл бұрын
lesson check😇
@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, } }
@definitelynotchris47764 ай бұрын
Pluto is a planet
@tedjames27312 ай бұрын
Succinct!
@aditya_asundi3 жыл бұрын
first
@lotar1228 Жыл бұрын
i know that i shouldn't be focusing on this but pluto is not a planet