小编MTZ*_*MTZ的帖子

c#中连字符的不间断字符是什么?

我使用“ \ u00A0”将空格替换为不间断空格。我需要连字符(破折号)。在C#中,最好的解决方案是什么?

编辑:我试图添加建议的字符,但“?” 出现而不是“-”。在调试中,我可以在转换过程中看到“-”,但最终会看到“-”。

我在其他帖子中发现,不是实际破折号的“-”可能会导致“?” 而不是破折号!(有关“-”和“?”的帖子)我需要一个解决方案,因为我需要一个不间断的破折号...

public void SetText(string text)
    {
        if (Mode == ControlMode.DesignTime)
        {
            string textToUse = string.Empty;
            string offlineScreenText = text;
            if (offlineScreenText != null)
            {
                int lblLen = Math.Min(Convert.ToInt32(_settings.MultilineLength), offlineScreenText.Length);
                textToUse = lblLen > 0 ? offlineScreenText.Substring(0, lblLen) : offlineScreenText;
            }

            _textBox.Text = textToUse;
        }
        else
        {
            if (!VerifyNumericValidity(text))
            {
                return;
            }

            _lastValue = text;

            // if there's a length limit, apply it to _lastValue 
            ApplyLengthLimit();

            if (text.Length > _textBox.MaxLength)
            {
                text = …
Run Code Online (Sandbox Code Playgroud)

c# wpf character hyphen

2
推荐指数
1
解决办法
1442
查看次数

标签 统计

c# ×1

character ×1

hyphen ×1

wpf ×1