Is short.Parse property or method?

I used short.Parse(somestring)in the past. But lately, I have seen confusing usage short.Parse()as below:

var shortArray = Array.ConvertAll(stringArr, short.Parse);

So, it Array.ConvertAllexpects an array and a converter. Well, fine! But how do we pass short.Parse as (or similar) a property? I did not find such a property in a Int16struct. So what is really going on here?

+4
source share
2 answers

Array.ConvertAllaccepts a delegate instance as the second parameter Converter<TIn, TOut>. The signature of this delegate is essentially the same as short.Parse- both return a value for one argument.

" " . .

, :

Array.ConvertAll(stringArr, new Converter<string, short>(short.Parse));

, : , . , , . ConvertAll : , short.Parse(element) , .

+5

short.Parse - . .

, (short.Parse()), (short.Parse).

, .

+5

Source: https://habr.com/ru/post/1625732/


All Articles