0
I have a program that inserts information into a CSV file. And I wanted to check if there is data in the variable if it does not show a message that there is no data entered in the file.
var csv = listForRegister.Select(l => String.Join(";",
l.DriverName.ToString(),
l.NationalId.ToString(),
l.InitialTime,
l.EndTime,
l.Distance.ToString()
+ " Km")).ToArray();
if ( csv == null )
{
string display = "Não ha registro nesta data.";
ClientScript.RegisterStartupScript(this.GetType(),
"yourMessage",
"alert('" + display + "');", true);
Response.Redirect(Page.Request.Path);
}
try to put your if the following way
if (csv == null || !csv.Any())
– Pablo Tondolo de Vargas