Reputation: 1167
Hi please could some interpret the following line of code into English?
"foo".TrimEnd(New Char(0 - 1) {})
I know what TrimEnd will do but not the Char bit.
Upvotes: 2
Views: 117
Reputation: 14088
I think this is a NOOP because TrimEnd()
is passed an empty array. This code will check if "o" (last character of "foo") is in the empty array, which it is not, and return "foo".
Upvotes: 2
Reputation: 27322
The code you posted is quite meaningless in the context posted so was this manipulated from some code you found or a made up example?
To answer your question:
TrimEnd
removes characters from the end of a string New Char(x)
creates an array of characters to be removed, x
specifies the size of the array0-1
specifies the upper bound of the array is -1
- this doesn't make much sense as the array starts at 0
and ends at -1
{}
initialises the character arrayUpvotes: 5