Note that there are some explanatory texts on larger screens.

plurals
  1. POC# overriding an interface contract method of a base class
    text
    copied!<p>I have created a converter class that uses the IValueConverter interface and InConverter. It is bound to a DataGrid and it is passed an array of strings in which it determines if the value is in the array.</p> <pre><code>[ValueConversion(typeof(int), typeof(bool))] public class InConverter : IValueConverter { public object Convert(object value, Type type, object parameter, CultureInfo info) { String str = value as String; String[] compareList = parameter as String[]; if (str != null) { foreach (String compare in compareList) { if (str == compare) return true; } } return false; } public object ConvertBack(object value, Type type, object parameter, CultureInfo info) { throw new NotImplementedException(); } } </code></pre> <p>I also have a conveter class called NotItConverter which essentially returns the opposite of InConverter and I didn't want to have to have redundant code. So, I pictured doing this.</p> <pre><code>[ValueConversion(typeof(int), typeof(bool))] public class NotInConverter : InConverter { public object Convert(object value, Type type, object parameter, CultureInfo info) { return !(Boolean)base.Convert(value, type, parameter, info); } public object ConvertBack(object value, Type type, object parameter, CultureInfo info) { throw new NotImplementedException(); } } </code></pre> <p>This doesn't work though. The only way to get it to complile without warning is to make the methods in NotInConverter specify override and the methods in InConverter specify virtual. Is there not an easier way to accomplish this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload