Torna al Thread

public class RatingToStringConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { // Validate parameters if (!(value is double)) { throw new NotSupportedException("Unsupported value type in RatingToStringConverter."); } // Convert number to string double doubleValue = Math.Floor((double)value); if (0.0 == doubleValue) { return "Awful"; } else if (1.0 == doubleValue) { return "Poor"; } else if (2.0 == doubleValue) { return "Fair"; } else if (3.0 == doubleValue) { return "Good"; } else if (4.0 == doubleValue) { return "Great"; } else { throw new ArgumentException("Unsupported value in RatingToStringConverter."); } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5