B-Arts DocumentationIndice generale

BConvert - Esempi

Conversioni con valore predefinito

using B.BStatics;

int quantity = BConvert.ToInt("12");
int fallbackQuantity = BConvert.ToInt(null, 0);
bool enabled = BConvert.ToBool("true");
string text = BConvert.ToString(null, "Valore non disponibile");

I metodi di conversione restituiscono il valore indicato dal parametro NullValue quando la conversione non produce un valore valido.

Verifica dei valori nulli

using B.BStatics;

object? value = DBNull.Value;

if (BConvert.IsNullOrDbNull(value))
  value = null;

Codifica e decodifica di testo

using B.BStatics;

byte[]? content = BConvert.ToByteArray("B-Arts", "UTF-8");

if (content != null)
{
  string text = BConvert.ToStringFromByte(content, "UTF-8");
}