Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert string into int type in c#
How to convert string into int type in c#
Use a converter. ToInt32 () function, such as Convert. ToInt32(" 123 ") converts the string" 123 "into an integer 123.

C# is a strongly typed language. Some of its numeric types can be implicitly converted, while others must be explicitly converted. Implicit conversion types can only be short-length types, and int can be converted into long, float, double and decimal, and vice versa.

Extended data:

All data types of C#:

1, basic data type

C# has a wider range of data types than C/C++ or Java. These types are bool, byte, ubyte, short, ushort, int, uint, long, ulong, float, double and decimal. Like C and C++, each data type has two types: signed and unsigned.

2. Two basic classes

The class named object is the base class of all other classes. A class named string is part of the object class language. Being part of a language means that the compiler can use it. Whenever a quoted string is written in a program, the compiler creates a string object to save it. ?

3. Parameter transfer

A method can be declared to accept a variable number of parameters. The default parameter passing method is to pass the value to the basic data type. The ref keyword can be used to force a variable to be passed by reference, which makes the variable accept the return value. The out keyword can also declare a reference passing procedure, which is different from ref in that it indicates that this parameter does not need an initial value.

4.COM's Integration

Perhaps the biggest selling point of C# for Windows program is its seamless integration with COM, which is Microsoft's Win32 component technology. In fact, it is possible to write COM clients and servers in any language. Net language. Classes written in C# can inherit existing COM components.

5. Index subscripts

An index is similar to an attribute, except that instead of using attribute names to refer to class members, it uses numbers in square brackets to refer anonymously (just like array subscripts).

6. Agency and feedback

A proxy object contains information needed to access a specific method of a specific object. Think of it as a clever method pointer proxy object that can be moved to another place and then accessed to make type-safe calls to existing methods.

Microsoft documents-conversion. ToInt32 method (single)?