W języku C# Jestem trochę zdziwiony, aby zrozumieć Enum.Czy można używać Enum z parami wartości jak słownik
W moim przypadku określon musiałbym sklepu stałą wartość w formacie Nazwa Wartość podobnego>
300 sekund = 5 minut
Obecnie używam tej klasy.
- Czy można zamiast tego używać Enum, więc klasa Enum będzie wyglądać lubi?
- Czy mogę przechowywać w wyliczeniu parę wartości?
Czy możesz podać mi próbkę kodu?
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;
}
}
}
Jaki jest cel wszystkich klawiszy "0"? Chcesz podać liczbę sekund? – atlaste
Dziękuję Stefan za wskazanie. Dokonałem edycji mojego pytania. – GibboK
Myślę, że powinieneś spojrzeć na klasę [TimeSpan] (http://msdn.microsoft.com/en-us/library/system.timespan.aspx) zamiast używać tych liczb. – Default