Answer the question
In order to leave comments, you need to log in
How to split long text into lines in C#?
It is necessary to divide the text into lines so that each has no more than a given number of characters, but at the same time the division (hyphenation) does not fall on a word (the word is not cut off).
Maybe there is a ready-made snippet?
Answer the question
In order to leave comments, you need to log in
You can, as suggested by Vladimir Martyanov :)
There is still an option - split by spaces and collect lines in turn, i.e. split by spaces - collect a string from the resulting pieces (and spaces, of course), along the way checking whether you exceed the allowed number of characters before adding. If you exceed - then this line is finished, form a new one :)
If you need no more than N characters in a string, look for a back space starting from a position that is a multiple of N. There will be a gap.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question