Data Type in Programming
I declared a variable as int data type which was a placeholder for a result status (meaning, based on the result status that variable varies from 0/1/2/3. It can contain only these four values).
“int” data type is 4 byte integer in C#. But I can declare this variable as “sbyte” which represents a 1 byte integer. Since that variable contains only 1 or 2 or 3 or 4, declaring the variable as “int” is wastage of memory space. Before declaring any variable we need to just think of the memory space needed for that variable, our requirement, any other good alternative for this variable. <<mod edit: delete advertising link>> |
elizas, I'm not a very experimented programmer, but I would suggest using the enum type. In C it's not very different from int, but as much as I know it will ease your life a bit.
|
Elizas;
If you want to advertise here, please see the links at the bottom of the page. |
Data Type in Programming
I declared a variable as “int” data type for a PatientId. It worked fine in local, but when that code went to LIVE, the application gave exception because in LIVE PatientId is too long to accommodate in int data type.
So before declaring any variable we need to consider all the situations, application scope, environment .Even one code may be working fine today, after 1/ 10/20 days/months/years it will fail due to just due to data type declaration mistake. Think more; write less is the policy for better programming. My Experience No 2: I declared a variable as int data type which was a placeholder for a result status (meaning, based on the result status that variable varies from 0/1/2/3. It can contain only these four values). “int” data type is 4 byte integer in C#. But I can declare this variable as “sbyte” which represents a 1 byte integer. Since that variable contains only 1 or 2 or 3 or 4, declaring the variable as “int” is wastage of memory space. Before declaring any variable we need to just think of the memory space needed for that variable, our requirement, any other good alternative for this variable. <<mod edit: deleted advertising link>> |
Second warning: Do not include the advertising link in any future posts
|
Why didn't the OP mention C# in the title?
And why isn't this in the Programming forum? |
1. probably because the posts were motivated by advertising (now removed)
2. because it may just get closed or deleted |
All times are GMT -5. The time now is 03:50 AM. |