How to add dot character after nth character of string in C #
how to add a decimal character after the second character of a string.
sample data = 78383083
desired op = 78.383083
code
string data = "011F03010A366B04AC07EB";
string longitude = data.Substring(14, data.Length - 14); //04AC07EB
string latitude = data.Substring(6, data.Length - 14); //010A366B
long lat=Convert.ToInt64(longitude, 16);//78383083
string latvalue=lat.ToString();
// string latvalue1=latvalue.Substr(0,2)+":"+latvalue.substr(2);
+3
Krishna mohan
source
to share
2 answers
You can use the insert () method in C # to insert a character at any position. Remember this is a zero based index.
string final_data = data.Insert(2,".");
You can read more about here .
+4
Aatish sai
source
to share
Keep it simple:
string result = data.Insert(2, ".");
+3
Mighty Badaboom
source
to share