What is the subset of int datatype in C#
Loading
What is the subset of int datatype in C#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Muhammad Imran AnsariPosted Oct 16, 2022, 8:02 AM
The subset of ‘int’ data type is long, float, double. Conversion may take place through Implicit/Explicit conversion.
An implicit conversion can be made when the value to be stored can fit into the variable without being truncated or rounded off. A variable of type long (64-bit integer) can easily store any value that an int (32-bit integer) can store.
A explicit conversion/cast is a way of explicitly informing the compiler that you intend to make the conversion and that you are aware that data loss might occur, or the cast may fail at run time.
Jignesh KumarPosted Oct 16, 2022, 4:27 AM
Hi Naresh,
Subset of int data type in C# long, float, double. When you do conversion from smaller type to bigger one then it will do implicit conversion but when you need to do reverse then you need to do explicit conversion and there may be chance of data loss.
Rajanikant HawaldarPosted Oct 15, 2022, 10:23 AM
Since,conversion of datatype is implicit type as 'int' is a subset of 'longtype' hence no need to explicitly convert data from one type to another. Compiler will automatically do conversion.