本文整理汇总了C#中Novacode.List.Last方法的典型用法代码示例。如果您正苦于以下问题:C# List.Last方法的具体用法?C# List.Last怎么用?C# List.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Novacode.List
的用法示例。
在下文中一共展示了List.Last方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFormattedTextRecursive
internal static void GetFormattedTextRecursive(XElement Xml, ref List<FormattedText> alist)
{
FormattedText ft = ToFormattedText(Xml);
FormattedText last = null;
if (ft != null)
{
if (alist.Count() > 0)
last = alist.Last();
if (last != null && last.CompareTo(ft) == 0)
{
// Update text of last entry.
last.text += ft.text;
}
else
{
if (last != null)
ft.index = last.index + last.text.Length;
alist.Add(ft);
}
}
if (Xml.HasElements)
foreach (XElement e in Xml.Elements())
GetFormattedTextRecursive(e, ref alist);
}
示例2: GetFormattedTextRecursive
internal static void GetFormattedTextRecursive(XElement Xml, ref List<FormattedText> alist)
{
FormattedText ft = ToFormattedText(Xml);
FormattedText last = null;
if (ft != null)
{
if (alist.Any())
last = alist.Last();
// Join adjacent runs that have the same formatting and do not cross a hyperlink boundary (they must both be inside a hyperlink or both be outside)
if (last != null && last.CompareTo(ft) == 0 && (last.containingHyperlinkId == null) == (ft.containingHyperlinkId == null))
{
// Update text of last entry.
last.text += ft.text;
}
else
{
if (last != null)
ft.index = last.index + last.text.Length;
alist.Add(ft);
}
}
if (Xml.HasElements)
foreach (XElement e in Xml.Elements())
GetFormattedTextRecursive(e, ref alist);
}
示例3: ConvertTermYearToTermId
/**
* Convert Term + Year to TermID. If Term + Year did not exist in databse. Will be create in database.
* @para: Term, Year
* @return: TermID
*/
public bool ConvertTermYearToTermId(int Term, int Year, ref int TermID)
{
/*
* Read TermTable from SQL to local variable for process
* TODO: Need enhanced work directly with database
*/
var m_TermDatabase = new List<TermDatabase>();
cmd.CommandText = @"SELECT * FROM TermTable ORDER BY TermID";
try
{
connection.Open();
reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
m_TermDatabase.Add(new TermDatabase((int) reader[0],(int) reader[1], (int) reader[2]));
}
}
connection.Close();
}
catch (Exception exception)
{
connection.Close();
MessageBox.Show(@"Message: " + exception.ToString(), @"Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
throw;
}
/*
* - Check in list and add to database if need.
*/
var TermFind = (m_TermDatabase.FindAll(x => x.Year == Year)).Find(y => y.Term == Term);
if (TermFind != null)
{
TermID = TermFind.TermID;
return true;
}
/*
* Term && Year did not exist in database. Add new Term to database. Begin from last Term in databas
* Example: In database contain Term 2 Year 2015. So new Term is 1 Year 2016. We should add Term from 3 Year 2015 to Term 1 Year 2016
* Add: (3,2015), (4,2015), (5,2015), (6,2015), (1,2016).
* If there is the first Term on database. We should add Term from Term 1 in this Year
* TermID have format: YearTerm. For Example: 20161 is Term 1 in 2016
*/
if (m_TermDatabase.IsEmpty())
{
connection.Open();
for (var i = 1; i <= Term; ++i)
{
cmd.CommandText = string.Format(@"INSERT INTO TermTable VALUES({0}, {1}, {2})", Year*10 + i, i, Year);
try
{
cmd.ExecuteNonQuery();
}
catch (Exception exception)
{
connection.Close();
MessageBox.Show(@"Message: " + exception.ToString(), @"Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
throw;
}
}
connection.Close();
}
else
{
connection.Open();
var lastYear = Convert.ToInt32(m_TermDatabase.Last().Year);
var firstYear = Convert.ToInt32(m_TermDatabase.First().Year);
var firstTermFirstYear = m_TermDatabase.First().Term;
var lastTermLastYear = m_TermDatabase.Last().Term + 1;
if (lastYear <= Year)
{
for (; lastYear <= Year; ++lastYear)
{
if (lastTermLastYear > 6)
lastTermLastYear = 1;
var tempTerm = lastYear < Year ? 6 : Term;
for (; lastTermLastYear <= tempTerm; ++lastTermLastYear)
{
if (Equals(lastYear, Year) && Equals(lastTermLastYear == Term))
TermID = lastYear * 10 + lastTermLastYear;
cmd.CommandText = string.Format(@"INSERT INTO TermTable VALUES({0}, {1}, {2})", lastYear * 10 + lastTermLastYear, lastTermLastYear,
lastYear);
try
{
cmd.ExecuteNonQuery();
}
catch (Exception exception)
{
connection.Close();
MessageBox.Show(@"Message: " + exception.ToString(), @"Error", MessageBoxButtons.OK,
//.........这里部分代码省略.........