Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Praticando Enumerador | Structs & Enumerators
C# Beyond Basics

Praticando EnumeradorPraticando Enumerador

Preencha os espaços em branco para completar a definição de enumeração. Leia o código e descubra qual é o nome do enum, bem como quais membros ele deve ter.

cs

index.cs

1. When we access an enum constant we use the enumName.constName syntax where enumName is the name of the enumerator.
2. The enum should have five elements. Look into the switch statement's cases to find out which constants are being accessed. One of them is Invisibility.

using System;

class Program
{
    enum Potion
    {
        Invisibility,
        Strength,
        Healing,
        FireResistance,
        Teleportation
    }

    static void Main(string[] args)
    {
        Potion potion = Potion.Invisibility;

        switch (potion)
        {
            case Potion.Invisibility:
                Console.WriteLine("You drink the Invisibility potion and vanish from sight!");
                break;
            case Potion.Strength:
                Console.WriteLine("You drink the Strength potion and feel a surge of power!");
                break;
            case Potion.Healing:
                Console.WriteLine("You drink the Healing potion and your wounds magically mend.");
                break;
            case Potion.FireResistance:
                Console.WriteLine("You drink the Fire Resistance potion and become impervious to flames.");
                break;
            case Potion.Teleportation:
                Console.WriteLine("You drink the Teleportation potion and find yourself in a new location!");
                break;
            default:
                Console.WriteLine("Invalid potion type!");
                break;
        }
    }
} 
      

Tudo estava claro?

Seção 2. Capítulo 11
course content

Conteúdo do Curso

C# Beyond Basics

Praticando EnumeradorPraticando Enumerador

Preencha os espaços em branco para completar a definição de enumeração. Leia o código e descubra qual é o nome do enum, bem como quais membros ele deve ter.

cs

index.cs

1. When we access an enum constant we use the enumName.constName syntax where enumName is the name of the enumerator.
2. The enum should have five elements. Look into the switch statement's cases to find out which constants are being accessed. One of them is Invisibility.

using System;

class Program
{
    enum Potion
    {
        Invisibility,
        Strength,
        Healing,
        FireResistance,
        Teleportation
    }

    static void Main(string[] args)
    {
        Potion potion = Potion.Invisibility;

        switch (potion)
        {
            case Potion.Invisibility:
                Console.WriteLine("You drink the Invisibility potion and vanish from sight!");
                break;
            case Potion.Strength:
                Console.WriteLine("You drink the Strength potion and feel a surge of power!");
                break;
            case Potion.Healing:
                Console.WriteLine("You drink the Healing potion and your wounds magically mend.");
                break;
            case Potion.FireResistance:
                Console.WriteLine("You drink the Fire Resistance potion and become impervious to flames.");
                break;
            case Potion.Teleportation:
                Console.WriteLine("You drink the Teleportation potion and find yourself in a new location!");
                break;
            default:
                Console.WriteLine("Invalid potion type!");
                break;
        }
    }
} 
      

Tudo estava claro?

Seção 2. Capítulo 11
some-alt