Link to home
Start Free TrialLog in
Avatar of bmanmike39
bmanmike39

asked on

How would I split a number at the decimal and put the two values in separate variables

Examples:  I get a return value of   49.85  I need to put the 49 in var1 and the  .85 in var2.  Ho do  i programmaticly split the values into the two variables?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In your code behind try this (and for example purposes I'll be using a Label (named Label1" that will be displaying your 49.85):
string s = Label1.Text.ToString();
            string[] parts = s.Split('.');
            int var1 = int.Parse(parts[0]);
            int var2 = int.Parse(parts[1]);

Open in new window

Avatar of bmanmike39
bmanmike39

ASKER

Thanks it works.