Monday, 10 October 2016

Converting From One Data Type to Another

Convert.ToXXX

XXX can be replaced by the .NET name of the type that we want to convert to.

Examples:

string age = "13"

int ageToInt = Convert.ToInt32(age);

when we check the value of ageToInt it should be 13;

We also have:

  • Convert.ToDouble();
  • Convert.ToBoolean();
  • Convert.ToInt16();
  • Convert.ToInt64();

No comments:

Post a Comment