G
Gani tpt
Guest
I am writing the below code. i am getting error below.
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Delegate to an instance method cannot have null 'this'.
complete source code
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("LIMETYPE", typeof(string)));
dt.Columns.Add(new DataColumn("DIG1", typeof(string)));
dt.Columns.Add(new DataColumn("DIG2", typeof(string)));
dt.Columns.Add(new DataColumn("DIG3", typeof(string)));
dt.Rows.Add(new object[] { "2", "", "4", "5" });
dt.Rows.Add(new object[] { "5(LIM)", "", "20", "" });
dt.Rows.Add(new object[] { "8(LIM)", "10", "", "" });
string resultval = "5(LIM)";
Qry = (from r in dt.AsEnumerable()
where ContainsStringExtensions.ContainsAny(r.Field<string>("LIMETYPE"), resultval)
&& !string.IsNullOrWhiteSpace(r.Field<string>("LIMETYPE"))
select new
{
}).Count();
if (Qry > 0)
{
//Getting Final value here
}
public static class ContainsStringExtensions
{
public static bool ContainsAny(this string haystack, IEnumerable<string> filterList)
{
return filterList.Any(haystack.Contains); //Error - Additional information: Delegate to an instance method cannot have null 'this'.
}
}
in my table some of the cells are blank. why the error is passing to "ContainsStringExtensions".
pls. give me suggestions and where to correct the code...?
Continue reading...
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Delegate to an instance method cannot have null 'this'.
complete source code
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("LIMETYPE", typeof(string)));
dt.Columns.Add(new DataColumn("DIG1", typeof(string)));
dt.Columns.Add(new DataColumn("DIG2", typeof(string)));
dt.Columns.Add(new DataColumn("DIG3", typeof(string)));
dt.Rows.Add(new object[] { "2", "", "4", "5" });
dt.Rows.Add(new object[] { "5(LIM)", "", "20", "" });
dt.Rows.Add(new object[] { "8(LIM)", "10", "", "" });
string resultval = "5(LIM)";
Qry = (from r in dt.AsEnumerable()
where ContainsStringExtensions.ContainsAny(r.Field<string>("LIMETYPE"), resultval)
&& !string.IsNullOrWhiteSpace(r.Field<string>("LIMETYPE"))
select new
{
}).Count();
if (Qry > 0)
{
//Getting Final value here
}
public static class ContainsStringExtensions
{
public static bool ContainsAny(this string haystack, IEnumerable<string> filterList)
{
return filterList.Any(haystack.Contains); //Error - Additional information: Delegate to an instance method cannot have null 'this'.
}
}
in my table some of the cells are blank. why the error is passing to "ContainsStringExtensions".
pls. give me suggestions and where to correct the code...?
Continue reading...