3

I am dumb founded at this statement....maybe its just too many hours/days of doing C# to VB.Net conversion but i am drawing a blank on this conversion.

Any help would be greatly appreciated.

List<string> sColors = new List<string>(this.CustomPaletteValues.Split(','));
try {
   List<Color> colors = sColors.ConvertAll<Color>(s => (Color)(new ColorConverter().ConvertFromString(s)));    

What i have so far:

Dim colors As List(Of Color) = sColors.ConvertAll(Of Color)(....)

As you can see its the content of the lambda that i am hitting a brick wall with.

3 Answers 3

1

Pardon the line breaks, but I believe this is what you want.

Dim colors As List(Of Color) = sColors.ConvertAll(Of Color)(
    Function(s) DirectCast((New ColorConverter).ConvertFromString(s), Color)
)
Sign up to request clarification or add additional context in comments.

1 Comment

thank you....found this kewl tool link Developer Fusion Toolbox
1
sColors.ConvertAll(Of Color)(Function(s) DirectCast(((New ColorConverter).ConvertFromString(s)), Color));

Comments

1

You can write it in a far more shorter way with implicit typing:

    Dim colors = sColors.ConvertAll(Of Color)(
        Function(s) (New ColorConverter).ConvertFromString(s))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.