EN
C# / .NET - convert space into non breaking space
0 points
In this article, we would like to show you how to convert space into non-breaking space in C#.
Quick solution:
xxxxxxxxxx
1
string text = "A B C";
2
string result = text.Replace(" ", "\u00A0");
In this example, we replace all spaces in the text
to non-breaking spaces (\u00A0
unicode) using Replace()
method.
xxxxxxxxxx
1
using System;
2
3
public class TestClass
4
{
5
public static void Main()
6
{
7
string text = "A B C";
8
9
string result = text.Replace(" ", "\u00A0");
10
11
Console.WriteLine(result);
12
}
13
}
Output:
xxxxxxxxxx
1
A B C