Hello!! I am trying to implement interface using ASP.NET and C# (I have used interface earlier). But I am having an issue regarding the written code below: How could the following error be resolved??
DAL: Repository.cs
public interface Repository
{
int coun(string cnt);
}
public class irep : Repository
{
public int coun(string cnt)
{
using (Demo2Entities db = new Demo2Entities())
{
var con = (from c in db.Country
where c.CountryName == cnt
select new { CountryName = c.CountryID }).ToList();
return con; //Error - Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'int'
}
}
}
Default.aspx.cs:
protected void Button1_Click(object sender, EventArgs e)
{
irep add ...
Go to the complete details ...