How to substring a value in a string Variable in C# RRS feed

  • Question

  • I am pulling data from a data grid storing the information in string variables in which i am passing them in a session variable to another page. I am need to get the value out of one of my string variables so i can do some calculations for longitude and latitude. how do i  do that when i don't know the decimal places and i need to substring 3 times? so pretty much break the whole value down.
    Example of what i need to do
     variable degree: -8
     variable Minutes: .3456*60 = 20.7360 = 20
    variable seconds: .7360*60

    • Edited by Gramboy Wednesday, September 24, 2008 4:55 PM
    Wednesday, September 24, 2008 4:43 PM

All replies

  • Hi Gramboy,

    This looks like a more general C# question, doesn't seem specific to the ReportViewer control. You might try a C# forum here at MSDN, such as this one:

    However, I would generally say that you probably want to take that initial string value and convert it into a double, using double.Parse(string value); Once it is a double, writing a function to do the conversion from decimal to dms should be pretty easy. If you search the web for "decimal degrees to degrees minutes seconds" you will find lots of good examples. If you are using a GIS library then they will have a utility function already written that does this.

    For example, I found this page which has a nice function to do the conversion:!DD16C3F34F4D913E!1803.entry

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, September 24, 2008 8:38 PM