Другой вариант - использовать ответ @rfmodulator в индексатор класса:
public class SafeValues
{
private readonly IDictionary<string, int> _dict = new Dictionary<string, int>();
public int this[string key]
{
get { return _dict[key]; } // you can also choose to use Math.Min
// in the getter to keep the original values in the underlying dictionary
// for debug purposes
set { _dict[key] = Math.Max(value, 160); }
}
}
Таким образом, вы можете использовать его как
var Resources = new SafeValues(); // you can easily set a parameter for the min value in the constructor if you want
Resources["CardSetIconWidth"] = (width-30)/260 * 160;