tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code07:07

C# enums 🪐

Bro Code ↗

From the creator

C# enums tutorial example explained #C# #enum #tutorial 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,

Published 2021-07-03 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code