C# int, Int32 and enums

The underlying type is indeed the same, but the compiler depends on the type to be as the exact alias. This is a compilation error based on parsing. I took a look at C# grammar specification and the underlying types defined there as tokens based on the alias (e.g. ‘int’, ‘unit’… etc.). The parser expects … Read more

What is the int.MaxValue on a 64-bit PC?

Yes, the answer will be the same on a 64-bit machine. In .NET, an int is a signed 32-bit integer, regardless of the processor. Its .NET framework type is System.Int32. The C# Language specification states: The int type represents signed 32-bit integers with values between –2,147,483,648 and 2,147,483,647.

Int to byte array

Update for 2020 – BinaryPrimitives should now be preferred over BitConverter. It provides endian-specific APIs, and is less allocatey. byte[] bytes = BitConverter.GetBytes(i); although note also that you might want to check BitConverter.IsLittleEndian to see which way around that is going to appear! Note that if you are doing this repeatedly you might want to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)