c# - Select and updating data from datatable -


i select data datatable, using following code,but throws exception not familiar with.

"index outside bounds of array."

tblrooms.select(idroom = 4) value of idroom in thetblroom don't know why causes error.

foreach (datarow dr in tblroomcart.rows) {       datarow drroom = tblrooms.select("idroom =" + dr["idroom"])[0];//here error in line  } 

as exception says,index out of bounds,you reading first element (with index 0) there no elements in collection.
same this:

int[] array = new int[0]; int x = array[0];//you exception here 

add if statement make sure there @ least 1 element,like:

int[] array = new int[0]; if (array.length > 0) {         int x = array[0]; } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -