Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Convert Datatypes...

Hello, in vb.net i use to use cStr or cLng etc.. to convert string from one cast to another... what do you do on c#?
0
wd006451
Asked:
wd006451
1 Solution
 
hackman_3vilGuyCommented:
Use casting whereby you put the type you want to convert to in brackets followed by what you want to convert

string a = "5";
int b = (int) a;

Or use:

System.Convert..... This contains methods for converting between nearly all datatypes.

Or use the Parse method if available eg:

string a  = "23/03/2005";
DateTime b = DateTime.Parse(a);

Enjoy
0
 
TertioptusCommented:
you should use Parse when going from a string to numeric value.

and Convert for all other cases
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now