Class: Convert

Namespace: System

Library: mscorlib.dll

It's an static Class: you can use the name Convert like the prefix/object.

The methods:

ToByte(somevalue)

ToBoolean(somevalue)

ToChar(somevalue)

ToDouble(somevalue)

ToFloat(somevalue)

ToInt16(somevalue)

ToInt32(somevalue)

Example:

ToInt64(somevalue)

IMPORTANT: The value needs to be in some compatible format. By example, we can't convert the string "6.37" to a type int.

You can use the method ToString() - valid for any object because it's from the root Class Object - for convertions to string.


PREVIOUS LESSON NEXT LESSON
T.CONTENTS HOMEPAGE