0

I am trying to remove specific unicode character in my string. Say we have below code .

public static string RemoveVerticalLine(this string source, char nil = ' ')
        {
            var s = '\u+007C';
            return new string(source.Select(c => c == s ? nil : c).ToArray());
        }

In the sample. I tried to remove the U+007c(Vertical Line). But I don't know why VS tell me error too many characters in character literal. Did I missed something?

enter image description here

1

1 Answer 1

5

That isn't how C# escape sequences work.

You need to write '\u007c'.

Or just use the actual character: '|'.

Sign up to request clarification or add additional context in comments.

3 Comments

what does it mean + ? why need to remove it ?
@Joe.wang: That's just the convention used when talking about Unicode code points. It has nothing to do with C# syntax. learn.microsoft.com/en-us/dotnet/csharp/programming-guide/…
Got it . Convention for the Unicode code point in c#, Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.