Как рассчитать длину списка
Я попытался вычислить длину списка
Это дает мне ошибку
Это мой классный файл
Что я уже пробовал:
Delete cfmdeletelist = new Delete(); List<Delete> DeleteList = new List<Delete>(); DeleteList = cfmdeletelist.getCurrentRow(); for(int i = 0; i < cfmdeletelist.length; i++)
Severity Code Description Project File Line Suppression State Error CS1061 'Delete' does not contain a definition for 'length' and no extension method 'length' accepting a first argument of type 'Delete' could be found (are you missing a using directive or an assembly reference?) eadd - Copy (2) C:\Users\Tan\Desktop\eadd - Copy (2)\StaffHomeLoan.aspx.cs 163 Active
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Configuration; using System.Data.SqlClient; using System.Data; using System.Text; /// <summary> /// Summary description for Delete /// </summary> public class Delete { public int loanterm { get; set; } public String Type { get; set; } public int loanrate { get; set; } public List<Delete> getCurrentRow() { List<Delete> deletelist = new List<Delete>(); // Step 4 :Retrieve connection string from web.config string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; // Step 5 :Create SQLcommand to select LoanTerm and LoanRate from LoanRate table where the rate is current StringBuilder sqlStr = new StringBuilder(); sqlStr.AppendLine("SELECT LoanRate,LoanTerm,Loanloantype From LoanMaster "); // Step 6 :Instantiate SqlConnection instance and SqlCommand instance SqlConnection myConn = new SqlConnection(DBConnect); SqlCommand cmd = new SqlCommand(sqlStr.ToString(), myConn); // Step 7 :Open connection then execute reader myConn.Open(); SqlDataReader reader = cmd.ExecuteReader(); // Step 8 : if reader has no rows return, set the typelist to null if (!reader.HasRows) { deletelist = null; } else while (reader.Read()) { Delete Deleted = new Delete(); Deleted.Type = reader["Loanloantype"].ToString(); Deleted.loanterm = Convert.ToInt32(reader["LoanTerm"]); Deleted.loanrate = Convert.ToInt32(reader["LoanRate"]); deletelist.Add(Deleted); List<Delete> distinct = deletelist.ToList(); } // Step 11: Close the reader and connection myConn.Close(); reader.Close(); return deletelist; } } // // TODO: Add constructor logic here // }