In c# I’m a little puzzled to understand Enum.
In my specif case I would need store constant value in a Name Value format like>
300 seconds = 5 minutes
At the moment I use this class.
- Would be possible to use Enum instead, so I the Enum class would look likes?
- Can I store in an Enum a Pair Values?
Could you provide me a sample of code?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MyWebSite.Models
{
public class Reminders
{
private sortedDictionary<int, string> remindersValue = new SortedDictionary<int, string>();
// We are settign the default values using the Costructor
public Reminders()
{
remindersValue.Add(0, "None");
remindersValue.Add(300, "5 minutes before");
remindersValue.Add(900, "15 minutes before");
}
public SortedDictionary<int, string> GetValues()
{
return remindersValue;
}
}
}
You could use a
Tuple<int, int>as dictionary key( at least with .NET >= 4 ).But since you actually want to store a
TimeSpan, use that as key.You can get the translation in this way: