Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6214541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:53:47+00:00 2026-05-24T06:53:47+00:00

I have created a converter class that uses the IValueConverter interface and InConverter. It

  • 0

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.

[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();
    }
}

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.

[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();
    }
}

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:53:48+00:00Added an answer on May 24, 2026 at 6:53 am

    I think it’s a combination of both suggestions:

    public class NotInConverter : InConverter, IValueConverter
    {
      new public object Convert(...)
      {
        return !base.Convert(...);
      }
    
      new public object ConvertBack(...)
      {
        return !base.ConvertBack(...);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a class that uses the KeyValuePair with List to store a
I have class X that implements an interface IX . I also have a
In my Android application I have created an SVG image converter class. It parses
I decided to create a currency converter in Java, and have it so that
I have created some JQuery that will expand a div 'popup' on hover and
I have created an android application that calls (using kSOAP library) a SOAP based
I have created a XAML UserControl that is used to enter the current date
I'm implimenting my own ApplicationContext class that uses the singleton pattern. I want to
I'm having a bit of trouble writing a class that uses generics because this
I have a Class X wich uses a Class Y. The X creates the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.