2

I am creating an app in UWP and actually noticed that the System.Converter and Array.ConvertAll functions doesn't exist in there... Why ? :/

Is there any way I could get them ?

Ahmad45123
  • 402
  • 1
  • 4
  • 15

1 Answers1

4

As you said, in UWP there is no System.Converter and Array.ConvertAll. You can however use the LINQ method Select to do the same work.

vmutafov
  • 91
  • 4
  • Small question, Could I just use a "Func<>" instead of "Converter<>", I guess it would do the same job right ? – Ahmad45123 Sep 09 '16 at 11:13
  • Yes, you can use Func<> instead of Converter<>. The only difference between the two is that Converter<> specifies by its name that this is a delegate which will convert something to something else. – vmutafov Sep 09 '16 at 11:23
  • Okay great and btw, Select doesn't exist too, I just used: `(from x in arr select (float)x).ToArray()`. – Ahmad45123 Sep 09 '16 at 11:50
  • What do you mean by "Select doesn't exist"? I tried the following: int[] arr = { 1, 2, 3, 4 }; float[] floatArr = arr.Select(x => (float)x).ToArray(); – vmutafov Sep 09 '16 at 11:56
  • IDK, It just told me that Select is undefined. And I did have LINQ referenced. – Ahmad45123 Sep 09 '16 at 19:02
  • Can you provide a screenshot? – vmutafov Sep 09 '16 at 19:07
  • Can someone explain how is this solution supposed to work? Im kind of new to this, an example would be nice – DemetrioProgramerOsorio Nov 16 '16 at 17:42
  • For anyone having the same issue in UWP, first make sure the using System.Linq is referenced then replace the ConvertAll with Select. – Milot25 Jan 23 '17 at 13:20