Home > Net >  C # type conversion principle (compiler how the data type conversion)
C # type conversion principle (compiler how the data type conversion)

Time:09-22

I is small white in c # industry just line into more than two month for just check information learned some type conversion principle, that is how the compiler for data type conversion, don't know right did not take notes but also want to record the hair posts, welcome each big teach teach, there is an error technology is put forward, little bro appreciate!

Get into the business,

Implicit type conversion should be substantially points is conversion, display conversion method of conversion, turn the custom in the categories, such as the compiler is implicit conversion and display conversion,

Implicit conversion: the compiler will judge data range, when the scope of the target data is greater than the source data range, the compiler doesn't do any action automatic conversion, or data security is no guarantee that the compiler complains, there may be others with is and the as operator, is operator, the compiler checks whether compatible with type, compatible returns TRUE, incompatible returns FALSE, the as keyword compiler also check compatibility, if not compatible returns null,

Display conversion: the compiler cannot know operation will cause the data security, when the source data type is greater than the target type, can capture source value, after the intercept value as the target, when the source type is less than the target type, the compiler will automatically fill character, make it the same as the target data, then as the target data, if the source type and size of the target type, the same as the value of the target type directly if the source type and target type incompatible compiler cannot convert complains,

Method transfer and custom conversion is called some API method, online great god summarizes a lot of I don't teach fish to swim,
  •  Tags:  
  • C#