Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to you check if byte[] is emoty. For string is example.length == 0 , how about byte[]?
Posted

Try:
C#
byte[] data = GetData();
if (data == null || data.Length == 0)
   {
   ...
 
Share this answer
 
Try this :

C#
byte[] Attachment = null ;
if (Attachment != null  && Attachment.Length > 0)
{
      //Your Code
}
else
{
     //Code for else
}



:) :) :)
 
Share this answer
 
Comments
Naz_Firdouse 3-Jun-14 9:22am    
if you assign null to byte[] and if the next statement checks for its null value, always else part gets executed....
Naz_Firdouse 3-Jun-14 9:23am    
moreover, the condition you specified is same as Solution 2 ...
Just check, it will do, do check the order conditions.

C#
if (byteArray != null  && byteArray.Length > 0)
 
Share this answer
 
Comments
anoym0us 3-Jun-14 8:22am    
i tried , btw this is for a fileupload control to check whether is there file uploaded

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