Type conversion in C,
Value types include integer, floating point, Boolean, String, DateTime, and Enum E (······)), structure type (Struct S (······))
Reference types include: string type, Class type (Object, Class C (·), interface type (Iterface I (······)), array type (one dimension and multi-dimensional array. Such as int [] and int [,])
The type conversion process is the packing and unpacking conversion process. The packing and unpacking conversion are specialized terms for type conversion. (Boxing conversion: implicit conversion of value type to reference type is allowed; reverse conversion of unpacking)
[Object class is the base class of all classes]
Basic type conversion:
1. automatic conversion (implicit conversion)
2. Forced conversion (display conversion)
3. Parse conversion (string value conversion)
Differences between automatic conversion and forced conversion:
1. Forced conversion can only be converted to the same type
2. automatic conversion can reference type conversion value type
[The value type can be converted to the reference type, but the reference type cannot be converted to the value type]
The automatic (implicit conversion) format is:
String s = "12.5 ";
Int t = Convert. ToDouble (s );
(Convert: data can be converted only when it meets the conditions of the type to be converted .)
Forced conversion (display conversion) format:
Double d = 23.6;
Int I = (int) d;
Parse conversion format:
String s = "3.14 ";
Float f = float. parse (s );
The brackets must be strings.
Additional packing and unpacking conversion:
Packing conversion:
Int I = 3;
String s = Convert. ToString (I );
Binning conversion:
String I = "3 ";
Double d = Convert. ToDouble (I );
Int s = (int) d;
In the C language, what is the symbol (->) and how to use it?
This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.
In the C language, what is the symbol (->) and how to use it?
This is a symbol in the struct pointer. Write a program to explain it, for example:
# Include <stdio. h>
Struct STU // define a struct
{
Int num;
} Stu;
Int main ()
{
Struct STU * p; // defines a struct pointer.
P = stu; // p points to the struct variable stu.
Stu. num = 100; // attaches an initial value to the struct member num.
Printf ("% d", p-> num); // output the num value in stu
Return;
}
As you can see, the-> method is to reference the variable in the struct !!
Format: p-> struct member (such as p-> num)
The function is equivalent to stu. num or (* p). num.
I don't know. You don't understand, and don't understand call me. O (∩ _ ∩) O ~
Hope to adopt it.