Reputation: 89
how to add a decimal symbol after 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);
Upvotes: 3
Views: 5288
Reputation: 4502
You can try this:
string str = "123456789";
if (str.Length > 5)
{
label1.Text = string.Concat(str.Substring(0, 5), "...");
}
else
{
label1.Text = str;
}
Upvotes: -1
Reputation: 1687
You can use the insert() method in C# to insert character in any position. Remember it is a zero based index.
string final_data = data.Insert(2,".");
You can learn more about here.
Upvotes: 4