I was having Cast problems when I was running a lambda and serializing to the service. Well, the solution was to pass everything to String and I did it. On the other side (Android App) I get and do what has to be done. Well, it turns out that this client has their dates loaded into the database as a float, like this one ( 79018 ). It turns out that when I give a float.Parse(data_string)
and then a Convert.ToDateTime(floatvalue)
, it gives the cast error saying that you can not cast Double to Single. If I post to single, continues the error, the same problem I was having before, which generated me some posts here. How do I make this value into DateTime?
private void listaLibera_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var libera = e.SelectedItem as Liberacao;
DateTime datas = Convert.ToDateTime(float.Parse(libera.DataLib));
lblTipoVenda.Text = "Tipo de Venda: " + libera.TipoVenda;
//lblVencimento.Text = "Vencimento: " + (Convert.ToDateTime(libera.Vendedor)).ToString("dd/mm/yyyy");
lblJuros.Text = "Juros: " + libera.Juros.ToString();
lblEntrada.Text = "Entrada: " + libera.Entrada;
lblAcrescimo.Text = "Acréscimo: " + libera.Acrescimo;
lblDesconto.Text = "Desconto: " + datas.ToString("dd/mm/yyyy");
}
I got the literal value and tried to convert and continue the cast error, like this: Convert.ToDateTime(79018.0f)
.