Good my query is this:
var items = new Normaslist();
try
{
conn.Open();
//using (var dr = cmd.ExecuteReader())
using (SqlDataReader dr = cmd.ExecuteReader())
{
in the code shown I define a variable items as a class Normaslist ()
[Serializable()]
public class Normaslist
{
public Normaslist()
{
//Lista = new List<Normalegal>();
}
public List<Normalegal> Lista = new List<Normalegal>();//{ get { return this.p_lista; } set { this.p_lista= value; }}
private List<Normalegal> p_lista;
public string TotalRowsn { get { return this.p_TotalRowsn; } set { this.p_TotalRowsn = value; } }
private string p_TotalRowsn;
public string TotalPagesn { get { return this.p_TotalPagesn; } set { this.p_TotalPagesn = value; } }
private string p_TotalPagesn;
}
I have tried replacing the definition of items with
Normaslist items = new Normaslist();
Also with
Normaslist items = Activator.CreateInstance<Normaslist>();
Both work normally when I compile them in c # 4.0 but when compiling it with c # 2.0 it does not work correctly. It does not show compile errors either. I would like to know if this is the correct way to define the variable items without using var in c # 2.0