Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

String Format In C# (more Advanced This Time!)

Featured Replies

Posted

Is there anyone in here who could help me with this little problem here:

I have a string of 30 chars, I want to divide that string into 3 lines with 10 chars at max per line.

Only problem is; NO WORDS SHOULD BE DIVIDED INTO 2 PARTS, it must stop and choose next line

if it see that the word is too long for the line....

What I have so far:

String[] Splitter = input.Split(new char[] { ' ' });

That code will then split the string into bits and parts, now to the rebuilding part where the actual help I need is needed.... Any good and valid suggestions?

/Regards, n00b

Um.. I think, you need to hardcode it.

For example like this:

		private void tbxInput_TextChanged(object sender, EventArgs e)
{
string[] Input = tbxInput.Text.Split(' ');
int Position = 0; tbxOutput1.Text = Split2Array(Input, ref Position);
tbxOutput2.Text = Split2Array(Input, ref Position);
tbxOutput3.Text = Split2Array(Input, ref Position);
} private string Split2Array(string[] IN, ref int POS)
{
string Split = "";
string OUT = "";
while ((Split.Length <= 10) && (POS < IN.Length))
{
Split += IN[POS];
if (Split.Length > 10) break;
OUT = Split;
POS++;
}
return OUT;
}

But it leaves out the spaces between the words..

  • Author

Thx for the reply UFO, but its still more efficient to use my old procedure than using yours im afraid :(

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.