我有以下 C# 类:
public class pageViews
{
public string dateTime {get; set;}
public string IPAddress {get; set;}
public string Page {get; set;}
public string Location {get; set;}
}
和以下数组列表:
List <pageViews> pviews = new List<pageViews>();
然后我创建类 pageViews
的实例并像这样填充字段:
pageViews views = new pageViews();
views.dateTime = reader["DateTime"].ToString();
views.IPAddress = reader["IPAddress"].ToString();
views.Page = reader["Page"].ToString();
然后我尝试像这样将类添加到数组列表中:
pviews.add(views);
但是我得到以下错误:
CS1061: 'System.Collections.Generic.List' does not contain a definition for 'add' and no extension method 'add' accepting a first argument of type 'System.Collections.Generic.List' could be found (are you missing a using directive or an assembly reference?)
根据我的阅读,我应该使用 linq,我已经在使用了:
using System;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
那么我缺少什么,因为据我所知,我拥有我所需要的一切?
最佳答案
关于java - 带有类的 C# 数组列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30544820/