Suggestion for SubstringOrDefault To Avoid Out Of Range Error with Substring Command and Having to First Check Length Is Longer #110794
Unanswered
robinwilson16
asked this question in
General
Replies: 0 comments 2 replies
-
API proposals would go to the runtime repository. Sounds like you already have a good solution in that extension method, does it really need to be added to the BCL? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When transferring data from one system to another or inserting user defined data you may not know how long the resulting string is but if you are inserting into a field that is 100 chars then if <= the max then you want to add it all but if over you may want to insert up to the limit.
For this reason having SubstringOrDefault would be handy and would save you having to only call the function if the string is at least that length to avoid an out of bounds error message.
Here is a definition of what it could look like:
Beta Was this translation helpful? Give feedback.
All reactions