Home > Forum > ASP.NET > error in split

error in split

by celv   on Mar 09, 2015   Category: ASP.NET  |  Views: 1103    |  Points: 5   |  Bronze 
  Reply
29*12.00=348

i need output as 348.00
but am getting as 348 only
string[] MyStr1s = hyrs.Split('.');
int hor1 = Convert.ToInt16(MyStr1s[0]);
int in1 = Convert.ToInt16(MyStr1s[1]);
TextBox8.Text = Convert.ToString(hor1);
TextBox9.Text = Convert.ToString(in1);
TextBox10.Text =TextBox8.Text + "." + TextBox9.Text;


Server Error in '/bramandam site' Application.

Index was outside the bounds of the array.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:




Bookmark and Share:
 
  User Reply  | Ask a question  |   Reply 
  Re :error in split   
by Thamil
on Mar 10 2015 12:17AM
Points : 10
Gold 
Hi Celv,

Can you explain the exact requirement.
  Re :error in split   
by John Prathip
on Dec 15 2015 9:48AM
Points : 10
Silver 
Hi celv,

My guess!

You have convert decimal to string.

example:

double output = 29 * 12.00;
string hyrs = output.ToString();//return 348

string[] MyStr1s = hyrs.Split('.');
int hor1 = Convert.ToInt16(MyStr1s[0]);---->348
int in1 = Convert.ToInt16(MyStr1s[1]);------->Index was outside the bounds of the array.

Recent Post

Latest Posts