Problem with List and TypeConverter

I am having a bit of difficulty with TypeConverters and Generic Lists and I was hoping that I could get a bit of advice.

I have a type converter that is used to create the constructor code for my component. (It is an XNA a Game Component, but I don't think that that has anything to do with the problem because it appears on a Winform) inside another component.

For instance I have the following:


Code highlighting produced by Actipro CodeHighlighter (freeware)

-->public class A{ private string s; public string SProp { get{ s = value;} set {return s;} }

public A() { s = ""; } public A(string inS) { s = inS; }}

By itself, when class A is an object on a form (or in my XNA Component) the TypeConverter code works fine, the property grid on the desinger is fine, if I debug the ConvertTo on the type converter I see that the variable s is all set up okay on the object.

However if on my form, I have a List<A>, the type converter works to an extent, as in it will add code to the perform the List.Add(new A("")), however the constructor with the parameter is not being called, instead the parameterless constructor is being called. 

Obviously, if the input to ConvertTo on the type converter is not set up, then my type converter won't work or display the values the user has put in.  This only occurs when my object is in a Generic List.

Can anyone suggest anything to look at?

tags: , , , ,

About Me: Paul Kinlan

I lead the Chrome Developer Relations team at Google.

We want people to have the best experience possible on the web without having to install a native app or produce content in a walled garden.

Our team tries to make it easier for developers to build on the web by supporting every Chrome release, creating great content to support developers on, contributing to MDN, helping to improve browser compatibility, and some of the best developer tools like Lighthouse, Workbox, Squoosh to name just a few.