int is 2 byte and char 4 byte why?
MD SHAMSE ALAM
Char: It is 2 bytes in C# because .NET uses UTF-16 for strings (UTF-32 would be 4 bytes). Almost all possible characters in human language can be expressed with 2 bytes (all English letters only require 1 byte) - SO Post: http://stackoverflow.com/questions/6781886/why-do-char-takes-2-bytes-as-it-can-be-stored-in-one-byteInt: This is 4 bytes (Int32). The only 2 byte numerical value in .Net is a short, which is (Int16). A nice SO reference: http://stackoverflow.com/questions/13351012/how-many-bytes-of-memory-does-each-type-in-net-consume-32-bit-environment
It depends on the processor. It can be two bytes or four bytes.
I know it's equal to sizeof(int). The size of an int is really compiler dependent. Back in the day, when processors were 16 bit, an int was 2 bytes. Nowadays, it's most often 4 bytes on a 32 bits system or 8 bytes on 64 bits system.
i think ur question is wrong mr shamse alam. integer size is: 4bytes and char size is only 2bytes in c# .net. their is no point in ur question saying int is 2 byte and char is 4 byte.. ur absolutely wrong...
https://msdn.microsoft.com/en-us/library/x9h8tsay.aspx
BECAUSE INT -NUMERICAL TYPE VALUE AND CHAR- CHARECTER TYPE VALUE
int takes 16 bit memory,so it take two byte.Actually char take one byte.In your case you may declare char[4] so it takes four byte.Generally character take 1 byte