Inserting C # char variables into ADO Char field (1)

I am experiencing this rather strange decimal complement to my char value during conversion. enter image description here

Tried the following conversion, but the decimal just keeps getting assigned along with the char to the variable:

  • Convert.ToChar(Console.ReadLine());

  • Console.ReadLine().ToString()[0];

  • Console.ReadKey().KeyChar;

An object containing a char field: objekt

Scheme:

Daten

@DAL Error: System.Data.SqlClient.SqlException: "String or binary data will be truncated.

USAGE: .NET Standard Libs

+3


source to share


2 answers


Your char is displayed with only a decimal value in front of it. So the decimal value is the ASCII value of the character. You can easily check this by typing the value and you will see that it only contains a character. If you want to test it while debugging, I would suggest using it employeeGrade.ToString()

in viewports.



It would be impossible for char to hold the value 90'Z ', because that would be multiple characters. You can see ASCII values ​​in ASCII table like this: http://ascii.cl/ .

+5


source


Use string data type for class



public string Grade { get; set; }

      

0


source







All Articles