Say you have a byte value equal to its max value, so byte aByte = 255;. When you increment a value past its max value, it usually wraps around to its minimum value, so if I were to write Console.WriteLine(++aByte), this would print 0 to the console because it can't exceed its max value.
I would like to have this same effect when it comes to enumerations I create. So let's say this is the code:
using System;
namespace CSharp_Test_003
{
class Program
{
static void Main()
{
Console.Title = "Enumerations";
Season currentSeason = Season.Spring;
Console.Write($"{currentSeason++} ");
Console.Write($"{currentSeason++} ");
Console.Write($"{currentSeason++} ");
Console.Write($"{currentSeason++} ");
Console.Write($"{currentSeason++} ");
}
private enum Season { Spring = 0, Summer, Autumn, Winter }
}
Currently this prints out:
Spring Summer Autumn Winter 4
But I would really like it to say "Spring" where there is a "4". If there's a practical way to make this possible I would really love to know.
intand not restricted to the values you specifybyte.MinValueis0.sbyteis signed its MinValue is -128