Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi.I know want when datatable.rows.count<0 in c#? ( Original)

edited version



Hi,

I want to check, is datatable has rows or not ?

For example,

if ( datatable has row only then run given code )
 {
    Do something;
 }
Posted
Updated 23-Jan-15 0:19am
v4
Comments
V. 23-Jan-15 5:38am    
This phrase doesn't make sense. Please update the question with a clearer question. (use google translate ?) :-)

I dont understand your question but for me it seems you want a if.

if (datatable.rows.count < 0)
{
// your code
}


check this for more information about if-else:
http://www.dotnetperls.com/if

Sorry if I didn't understood your question properly, tried my best im still a beginner too.
 
Share this answer
 
v4
Comments
Member 10670025 23-Jan-15 6:32am    
I want know when (datatable.rows.count < 0) happen?
Hi,
i edited your question as par my understanding.

let see there will be two cases


C#
if (datatable.rows.count > 0)
{
   // this code will run if data table has more than 0 rows, means there is at least 1 row in  data table, data table is not empty.
}


C#
if (datatable.rows.count < 1)
{
   // this code will run if data table does not has any data (means empty data table, 0 rows).
}
 
Share this answer
 
v2
Comments
Member 10670025 23-Jan-15 6:33am    
I want know when (datatable.rows.count < 0) happen?
Santosh K. Tripathi 23-Jan-15 6:45am    
as you are saying

datatable.rows.count < 0

it means data table has less than zero row. even if a data table is empty still it's row count is zero (0).

so row count in negative number doesn't makes any seance.

Please explain your question by giving some good example, so we can understand.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900