Question TypeConverter gets error "marked as override cannot be marked as new or virtual"

tim8w

Well-known member
Joined
Sep 8, 2020
Messages
131
Programming Experience
10+
I am trying to write a TypeConverter, but everyone I try and add gets the error "marked as override cannot be marked as new or virtual". Below is a sample of one of them:

C#:
    public class DefectCollectionParametersTypeConverter : ExpandableObjectConverter
    {
        public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType)
        {
            if ((sourceType == typeof(string)))
                return true;
            return base.CanConvertFrom(context, sourceType);
        }
    }

What am I doing wrong?
 
I just pasted that exact code into a project and it worked for me. If I added the new or virtual keyword to the method declaration then I got the error message you describe. While we generally recommend posting formatted code rather than screenshots, this seems like a situation where it might help:

1601102117318.png


1601102161630.png
 
Back
Top Bottom