本文整理汇总了C#中WebApplication1.List.Add方法的典型用法代码示例。如果您正苦于以下问题:C# List.Add方法的具体用法?C# List.Add怎么用?C# List.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebApplication1.List
的用法示例。
在下文中一共展示了List.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Marchant
public Marchant()
{
Products = new List<Product>();
Products.Add(new Product("Pen", 25));
Products.Add(new Product("Pencil", 30));
Products.Add(new Product("Notebook", 15));
}
示例2: databasecall
public DataTable databasecall(string username)
{
var con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
SqlConnection mycon = new SqlConnection(con);
try
{
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand("Select * from Demo where [email protected]", mycon);
cmd.Parameters.AddWithValue("@NAME", username);
mycon.Open();
SqlDataReader DR1 = cmd.ExecuteReader();
{
if (DR1.HasRows)
dt.Load(DR1);
}
//converting it to list
List<DataRow> list = new List<DataRow>();
foreach (DataRow dr in dt.Rows)
{
list.Add(dr);
}
//converting it to list
return dt;
}
catch (Exception e)
{
// cmd.ExecuteScalar();
mycon.Close();
return null;
}
}
示例3: sqlstringtext
public static string sqlstringtext()
{
string appPath = HttpRuntime.AppDomainAppPath + @"\sql.txt";
//string appPath = @"c:\Users\" + Environment.UserName + @"\Desktop\sql.txt";
List<string> lines = new List<string>();
using (StreamReader r = new StreamReader(appPath, Encoding.Default))
{
string line;
while ((line = r.ReadLine()) != null)
{
lines.Add(line);
}
}
string sqltext = "";
foreach (string s in lines)
{
//string[] words = s;
sqltext = s.Trim();
//words[0] = "";
//words[1] = "";
}
return sqltext;
}
示例4: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
int sheet_number = Convert.ToInt32(TextBox1.Text);
int column_number = Convert.ToInt32(TextBox2.Text);
string cell_entry = "";
List<string> list_images = new List<string>();
foreach (Row row in (((Workbook.Worksheets(excel_path)).ElementAtOrDefault(sheet_number-1)).Rows))
{
if (row.Cells.ElementAtOrDefault(column_number-1) != null)
{
cell_entry = (row.Cells.ElementAtOrDefault(column_number-1)).Text;
list_images.Add(cell_entry);
}
}
List<string> distinct_images = list_images.Distinct().ToList();
foreach (var images in distinct_images)
{
System.Drawing.Image image = DownloadImageFromUrl("https://media.loylty.com/Gallery/" + images + ".jpg");
if (image != null)
{
string rootPath = ConfigurationManager.AppSettings["FolderPath1"];
string fileName1 = Server.MapPath(rootPath + images + ".jpg");
image.Save(fileName1);
}
}
}
示例5: GetSeriesString
private string GetSeriesString()
{
List<Expense> expenses = Expense.GetAmountRandomAmountList();
List<string> expensesLinePoints = new List<string>();
StringBuilder seriesString = new StringBuilder();
foreach (Expense expenseItem in expenses)
{
expensesLinePoints.Add(expenseItem.Amount.ToString());
if (expenseItem.Date.Month == 12)
{
if (seriesString.Length > 0)
{
seriesString.Append(",");
}
seriesString.Append("{ ");
seriesString.AppendFormat(@"name: {0},
data: [{1}]", expenseItem.Date.Year, string.Join(",", expensesLinePoints.ToArray()));
seriesString.Append(" }");
expensesLinePoints = new List<string>();
}
}
return seriesString.ToString();
}
示例6: ProcessRequest
public void ProcessRequest(HttpContext context)
{
var userno = context.Request["userno"];
DateTime myDate = DateTime.Now;
string myDateString = myDate.ToString("yyyy-MM-dd HH:mm:ss");
String time_start = DateTime.UtcNow.AddDays(-365).ToString("yyyy-MM-dd hh:mm:ss");
Console.WriteLine(myDateString, time_start);
List<item_reminder> items = new List<item_reminder>();
using (var sql_conn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.AppSettings["ConnectionStr"]))
{
sql_conn.Open();
using (var sql_cmd = sql_conn.CreateCommand())
{
var comm = string.Format("SELECT [pro_userno],[descr],[CreateDate] FROM HP_reminder WHERE userno = '{0}' and (CreateDate BETWEEN '{1}' AND '{2}') ORDER BY CreateDate DESC ", userno, time_start, myDateString);
sql_cmd.CommandText = comm;
sql_cmd.ExecuteNonQuery();
SqlDataReader sqlite_datareader1 = sql_cmd.ExecuteReader();
while (sqlite_datareader1.Read())
{
items.Add(new item_reminder()
{
pro_userno = sqlite_datareader1["pro_userno"].ToString(),
descr = sqlite_datareader1["descr"].ToString(),
CreateDate = DateTime.Parse(sqlite_datareader1["CreateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")
});
}
String data = JsonConvert.SerializeObject(items);
context.Response.Clear();
context.Response.ContentType = "application/json ; charset =utf-8";
context.Response.Write(data);
context.Response.End();
}
}
}
示例7: ProcessRequest
public void ProcessRequest(HttpContext context)
{
String today = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
List<item_public> items = new List<item_public>();
using (var sql_conn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.AppSettings["ConnectionStr"]))
{
sql_conn.Open();
using (var sql_cmd = sql_conn.CreateCommand())
{
var comm = string.Format("SELECT acttitle, actbdate,actedate, content , name ,telephone ,cellphone FROM hactivity where bucd ='wkhm' and actedate >='{0}' ORDER BY actedate DESC ", today);
sql_cmd.CommandText = comm;
sql_cmd.ExecuteNonQuery();
SqlDataReader sqlite_datareader1 = sql_cmd.ExecuteReader();
while (sqlite_datareader1.Read())
{
items.Add(new item_public()
{
acttitle = sqlite_datareader1["acttitle"].ToString(),
actbdate = DateTime.Parse(sqlite_datareader1["actbdate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"),
actedate = DateTime.Parse(sqlite_datareader1["actedate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"),
content = sqlite_datareader1["content"].ToString(),
name = sqlite_datareader1["name"].ToString(),
telephone = sqlite_datareader1["telephone"].ToString(),
cellphone = sqlite_datareader1["cellphone"].ToString()
});
}
String data = JsonConvert.SerializeObject(items);
context.Response.Clear();
context.Response.ContentType = "application/json ; charset =utf-8";
context.Response.Write(data);
context.Response.End();
}
}
}
示例8: LinkButton1_Click
protected void LinkButton1_Click(object sender, EventArgs e)
{
char[] trimmer={' '};
List<string> keywords = TextBox2.Text.Split(',').ToList();
List<string> filteredKeywords = new List<string>();
foreach (string word in keywords)
{
string temp = word.ToLower();
temp = temp.TrimEnd(trimmer);
temp = temp.TrimStart(trimmer);
filteredKeywords.Add(temp);
}
float CSMatch = Comparator.matchSpringerCS(filteredKeywords.ToArray());
float ENMatch = Comparator.matchSpringerEngineering(filteredKeywords.ToArray());
float MAMatch = Comparator.matchSpringerMA(filteredKeywords.ToArray());
SCS.Text = " Computer Science: " +CSMatch + "%";
SEN.Text = " Engineering: " + ENMatch + "%";
SMA.Text = " Mathematics: " + MAMatch + "%";
; ;
}
示例9: checkClassPrereqs
// checks whether student satisfies prereqs for given CourseNumber
// string => bool
protected bool checkClassPrereqs(string CourseNumber)
{
List<string> PrereqSetIDs = new List<string>();
SqlDataReader rdr;
//gets PrereqSetIDs for CourseNumber from server, puts them in PrereqSetIDs
string sql = "SELECT PrereqSetID FROM wi.tbl_prereq_set WHERE CourseNumber = @CourseNumber;";
MyConnection.Open();
SqlCommand cmd = new SqlCommand(sql, MyConnection);
cmd.Parameters.Add("@CourseNumber", System.Data.SqlDbType.VarChar);
cmd.Parameters["@CourseNumber"].Value = CourseNumber;
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//PrereqSetIDs.Add(rdr.GetString(0));
PrereqSetIDs.Add(rdr.GetValue(0).ToString());
}
if (cmd != null) cmd.Dispose();
if (MyConnection != null) MyConnection.Close();
if (rdr != null) rdr.Dispose();
MyConnection.Close();
//for each PrereqSetID, gets its classes from server and checks whether studenthistory contains them
foreach (string PrereqSetID in PrereqSetIDs)
{
List<string> PrereqSet = new List<string>();
bool setRet = false;
sql = "SELECT Prereq FROM wi.tbl_prereq WHERE PrereqSetID = @PrereqSetID;";
MyConnection.Open();
cmd = new SqlCommand(sql, MyConnection);
cmd.Parameters.Add("@PrereqSetID", System.Data.SqlDbType.VarChar);
cmd.Parameters["@PrereqSetID"].Value = PrereqSetID;
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//checks if returned classes are in StudentHistory
if (studentHistory.Contains(rdr.GetString(0))) setRet = true;
}
if (cmd != null) cmd.Dispose();
if (MyConnection != null) MyConnection.Close();
if (rdr != null) rdr.Dispose();
MyConnection.Close();
//returns false if the PrereqSet isn't satisfied
if (!setRet) return false;
}
if (cmd != null) cmd.Dispose();
if (MyConnection != null) MyConnection.Close();
if (rdr != null) rdr.Dispose();
MyConnection.Close();
//returns true if no prereqs are missing for the PrereqSets
return true;
}
示例10: PopulateDropDownList
public static List<Customers> PopulateDropDownList()
{
DataTable dt = new DataTable();
List<Customers> objDept = new List<Customers>();
using (SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=ylena_exercise;Integrated Security=True"))
{
using (SqlCommand cmd = new SqlCommand("SELECT CustomerId, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
objDept.Add(new Customers
{
CustomerId = dt.Rows[i]["CustomerId"].ToString(),
CustomerName = dt.Rows[i]["CustomerName"].ToString(),
ContactName = dt.Rows[i]["ContactName"].ToString(),
Address = dt.Rows[i]["Address"].ToString(),
City = dt.Rows[i]["City"].ToString(),
PostalCode = dt.Rows[i]["PostalCode"].ToString(),
Country = dt.Rows[i]["Country"].ToString()
});
}
}
return objDept;
}
}
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var myLog = new List<string>();
myLog.Add(string.Format("{0} - Logging Started", DateTime.UtcNow));
logListView.DataSource = myLog;
logListView.DataBind();
}
示例12: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
List<MyRecord> myRecordList = new List<MyRecord>();
myRecordList.Add(new MyRecord() { Id = 1, Name = "John" });
myRecordList.Add(new MyRecord() { Id = 2, Name = "Sue" });
myRecordList.Add(new MyRecord() { Id = 3, Name = "Jack" });
DropDownList1.DataSource = myRecordList;
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "Id";
DropDownList1.DataBind();
using (SqlConnection cn = new SqlConnection())
{
}
}
示例13: acm
public static List<string> acm(string uri)
{
List<string> acmkeywords = new List<string>();
int counter = 0;
string ccsforthisarticle = "CCS for this Article";
string end = "]);";
bool printNow = false;
string quoteandgreatersymbol = "\">";
string path = HttpContext.Current.Server.MapPath("~/App_Data/ACMhtmlFile.txt");
Stream writer = new FileStream(path, FileMode.Create);
writer.Close();
// string link = "http://dl.acm.org/citation.cfm?id=1073209&CFID=574953640&CFTOKEN=74149999";
using (WebClient client = new WebClient())
{
client.DownloadFile(uri, path);
foreach (var line in File.ReadLines(path))
{
if (printNow)
{
if (line.Contains(end))
{
printNow = false;
counter++;
}
}
if (printNow)
{
if (line.Contains(quoteandgreatersymbol))
{
var a = line.IndexOf("href");
var b = line.LastIndexOf("/a>");
var c = line.Substring(a, b - a);
var d = c.IndexOf('>');
var e = c.IndexOf('<');
var f = c.Substring(d, e - d);
acmkeywords.Add(f.Trim('>'));
System.Diagnostics.Debug.WriteLine(f.Trim('>'));
}
}
if ((line.Contains(ccsforthisarticle)) && counter == 0)
printNow = true;
}
}
return acmkeywords;
}
示例14: ProcessRequest
public void ProcessRequest(HttpContext context)
{
var userid = context.Request["userid"];
String data = "";
List<item_check> items = new List<item_check>();
using (var sql_conn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.AppSettings["ConnectionStr"]))
{
sql_conn.Open();
using (var sql_cmd = sql_conn.CreateCommand())
{
var comm = string.Format("SELECT userid FROM employees where userid = '{0}' ", userid);
sql_cmd.CommandText = comm;
sql_cmd.ExecuteNonQuery();
SqlDataReader sqlite_datareader1 = sql_cmd.ExecuteReader();
while (sqlite_datareader1.Read())
{
items.Add(new item_check()
{
userid = sqlite_datareader1["userid"].ToString(),
});
}
data = JsonConvert.SerializeObject(items);
if (data == "[]")
{
context.Response.Clear();
context.Response.ContentType = "application/json ; charset =utf-8";
context.Response.Write("YES");
context.Response.End();
}
else
{
context.Response.Clear();
context.Response.ContentType = "application/json ; charset =utf-8";
context.Response.Write("NO");
context.Response.End();
}
context.Response.Clear();
context.Response.ContentType = "application/json ; charset =utf-8";
context.Response.Write(data);
context.Response.End();
}
}
}
示例15: GetImgSrc
/// <summary>
/// 匹配页面的图片地址
/// </summary>
/// <param name="HtmlCode"></param>
/// <param name="imgHttp">要补充的http://路径信息</param>
/// <returns></returns>
public List<string> GetImgSrc(string HtmlCode)
{
List<string> list = new List<string>();
string Reg = @"";
Reg = "(?is)<img.*?src=(['\"]?)(?<url>[^'\" ]+)(?=\\1)[^>]*>";
foreach (Match m in Regex.Matches(HtmlCode, Reg, RegexOptions.IgnoreCase))
{
list.Add(m.Groups["url"].Value);
}
return list;
}