i have created an app that basically looks for blob records on a mysql server problem i have is that if for whatever reason the blob field is empty the app crashes. I thought on something like
i currently have
byte[] data = (byte[])DbReader[2];
but i was wondering if there is any way to do something like
if (DbReader.IsDbNull(2)
byte[] data = /* DEFAULT VALUE */
else
byte[] data = (byte[])DbReader[2];
but can i set a default value?? everything ive tried fails 🙁
How about this:
Arrays are reference types so you can assign null to them. Later on you will be able see if data is null just like this:
EDIT: simplification
You could simplicate your code like this: