Why I'm getting CS1012: Too many characters in character literal and CS0019?
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'"
Error: too many characters in character literal asp.net
"too many characters in character literal" is caused by having a char-literal with too many characters in it.
You have probably mixed up the '
-character and the "
-character.
The error probably lies in your "android.aspx.cs"-file rather than the .aspx-file that you have provided.
Could you provide the code for that as well?
Well, your problems are right here:
<%# Bind('ModelID') %>
Replace your single-quotes with double-quotes and you will be golden!
<%# Bind("ModelID") %>
Same goes for all your Evals/Binds
Also see these questions:
Why I'm getting CS1012: "Too many characters in character literal" and CS0019?
Too many characters in character literal?
Console.Write(new string('* ', n) Too many characters in character literal
char
name refers to character, and in '* '
code there are two characters: '*'
and ' '
(whitespace). Therefore, it should be a string, characters and strings differ by type of quotes: '
vs "
. Unfortunately, there is no overload of string
constructor to accept another string and multiplier. So you need to reproduce same logic with different approach. One of them is below
var newStr = string.Join(string.Empty, Enumerable.Repeat("* ", 3));
Too many character in character literal
You need double quotes for strings in C#. Single quotes are for characters:
Eval("FirstColorCode")
Printing a sharp sign character
I am trying to print this Unicode character(and many others) but the Console displays a '?'.
The problem is not with the character, but it's the console not being configured the correct font to display this character.
You can manually set a console's Font, here's a tutorial on how to do it. I don't know of a way to set it programmatically (yet).
https://www.tenforums.com/tutorials/93961-change-console-window-font-font-size-windows.html
Here's a .net Fiddle: https://dotnetfiddle.net/xLvRq2
using System;
public class Program
{
public static void Main()
{
char kjfnv = '\u266F';
Console.WriteLine(kjfnv);
}
}
Output:
♯
Update:
my personal set of applicable fonts in the console is very limited - meaning: I am not able to display the character.
However, the .net fiddle proves the methodology is correct - meaning: changing your console host, or find a way to make use of the correct font in Console should do the trick.
Here's a article on how to change fonts in powershell. Possibly a similar thing exists for the default console host: https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/adding-more-fonts-to-powershell-console
@EricMovsessian: wasn't able to get this working without seriously needing to change some default values. For me this is not worth further investigation.
Keep in mind Console graphic capabilities are very limited, perhaps you want to consider an alternative technique, or just use the number sign #
as a substitute
Related Topics
Extract Thumbnail for Any File in Windows
How to Generate Unique Public and Private Key via Rsa
How to Compare Lists in Unit Testing
Convert String to System.Io.Stream
How to Test Your Request.Querystring[] Variables
How to Open a Web Page from My Application
Why Does the Is Operator Return False When Given Null
Visual Studio 2015 Break on Unhandled Exceptions Not Working
Intersect with a Custom Iequalitycomparer Using Linq
How to Access Session in a Webmethod
How to Apply a General Rule for Remapping All Property Names When Serializing with JSON.Net
Multiple Where Clauses with Linq Extension Methods
How to Capitalize First Letter of First Name and Last Name in C#
Read a Xml (From a String) and Get Some Fields - Problems Reading Xml
Using Iconfiguration in C# Class Library
What's the Best Way to Test SQL Server Connection Programmatically