本文整理汇总了C#中Common.List.Take方法的典型用法代码示例。如果您正苦于以下问题:C# List.Take方法的具体用法?C# List.Take怎么用?C# List.Take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.Take方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnShowZones
void OnShowZones()
{
var zonesSelectionViewModel = new ZonesSelectionViewModel(Device, Zones);
if (DialogService.ShowModalWindow(zonesSelectionViewModel))
{
Zones = zonesSelectionViewModel.Zones;
Zones = Zones.Take(50).ToList();
OnPropertyChanged("PresenrationZones");
}
}
示例2: Execute
private void Execute()
{
List<byte> rxBuff = new List<byte>();
while(true)
{
byte[] read = new byte[1];
try
{
// Read
int rxed = _socket.Receive(read, read.Length, SocketFlags.None);
// Add data to buffer
rxBuff.AddRange(read.Take(rxed));
// process data if it contains a terminating character
if (rxBuff.Contains(0x02))
{
// retreive the string
string rxStr = Encoding.UTF8.GetString(rxBuff.Take(rxBuff.IndexOf(0x02)).ToArray());
// remove the data that was just converted into a string (plus the 0x02 terminator)
rxBuff.RemoveRange(0, rxBuff.IndexOf(0x02) + 1);
// Deserialize to the message structure
Message msg = JsonConvert.DeserializeObject<Message>(rxStr);
// Notify all listeners
if (msg != null)
{
OnMessageRxed(msg);
}
}
}
catch
{
OnDisconnected();
}
}
}
示例3: GetTagList
/// <summary>
/// 获取Tag集合
/// </summary>
public List<TagInfo> GetTagList(int tid, int count)
{
List<TagInfo> tags = new List<TagInfo>();
IQueryable<blog_varticle> articles=GetArticles(tid, 0,0);
string tagstr = "";
foreach (blog_varticle article in articles)
{
tagstr += article.tags.Trim() + ",";
}
string[] arrTag = tagstr.Split(',');
arrTag = Utils.DistinctStringArray(arrTag);
foreach (string a in arrTag)
{
if (a.Trim() != "")
{
tags.Add(new TagInfo { Tag = a.Trim(), Count = Utils.RegexCount(a, tagstr) });
}
}
tags.Sort(delegate(TagInfo x, TagInfo y) { return y.Count - x.Count; });
if (count > 0)
tags = tags.Take(count).ToList();
return tags;
}
示例4: ShowMoreRecords
/// <summary>
/// Function to get more search records.
/// </summary>
/// <param name="presenter">The presenter</param>
/// <param name="numberOfRecords">The number of records.</param>
/// <param name="searchText">The search text.</param>
/// <returns>
/// The partial view
/// </returns>
public ActionResult ShowMoreRecords(GlobalSearchPresenter presenter, int numberOfRecords, string searchText)
{
if (presenter != null)
{
IList<SearchResultItem> searchResult = new List<SearchResultItem>();
if (SessionData.Instance.GlobalSearchItems != null)
{
IList<SearchResultItem> searchRecordList = new List<SearchResultItem>();
searchRecordList = SessionData.Instance.GlobalSearchItems;
presenter.AssignAllSearchRecordList(searchRecordList);
int totalCount = presenter.RecordCount + numberOfRecords;
presenter.RecordCount = totalCount < searchRecordList.Count ? totalCount : searchRecordList.Count;
searchResult = searchRecordList.Take(presenter.RecordCount).ToList<SearchResultItem>();
presenter.AssignSearchResultList(searchResult);
}
}
return this.PartialView(SearchRecordsPartialView, presenter);
}