Variable in C#

mansiten

Новичок
Joined
Sep 7, 2023
Messages
15
Reaction score
6
Points
3
Help with variable in C#
How can I pass a variable in which I have coordinates 48.2569 that are string, taken from json.
I want to be able to convert them to a number and be able to add another number.

For example
project.Variables["geo_lat"].Value= 48.555

but right now it's a string and can not add any.
How do I change it to Number, and reassign the same value but changin a number.

Thanks
 

myndeswx

Client
Joined
May 15, 2017
Messages
437
Reaction score
104
Points
43
var someCoordinate= Convert.ToDouble(project.Variables["latitude"].Value);
//do some maths in here

//at the end convert it back to string rounding to 7 after the dot
project.Variables["latitude"].Value = Math.Round(someCoordinate,7).ToString();


For more fancy stuff with coordinates look in to NET System.Device.Location :az:
 
  • Thank you
Reactions: mansiten

mansiten

Новичок
Joined
Sep 7, 2023
Messages
15
Reaction score
6
Points
3
var someCoordinate= Convert.ToDouble(project.Variables["latitude"].Value);
//do some maths in here

//at the end convert it back to string rounding to 7 after the dot
project.Variables["latitude"].Value = Math.Round(someCoordinate,7).ToString();


For more fancy stuff with coordinates look in to NET System.Device.Location :az:
Thanks Bro!! :az:
 
  • Thank you
Reactions: myndeswx

Users Who Are Viewing This Thread (Total: 1, Members: 0, Guests: 1)