Why I'm getting CS1012: “Too many characters in character literal” and CS0019?

前端 未结 1 634
广开言路
广开言路 2020-11-29 12:02

When trying to upload something to Imgur, I have to put an Authorization in. I do it with WebRequest.Headers but it gives me three errors.

2 times CS101

相关标签:
1条回答
  • 2020-11-29 12:22

    You're trying to use single quotes for string literals - that's invalid in C#. Single quotes are for character literals (char). You need double quotes for string literals. You also need parentheses for a method call:

    webRequest.Headers["Authorization"] = "Bearer " + GetToken();
    

    (Note that this has nothing to do with imgur or WebRequest - it's just normal C#.)

    Links to MSDN explanations with samples:

    • CS1012 - "Too many characters in character literal"
    • CS0019 - "Operator 'operator' cannot be applied to operands of type 'type' and 'type'"
    0 讨论(0)
提交回复
热议问题