public IEnumerable <dynamic> GetHighlightsItemsContentByGroupId(int groupId, DisplayTemplate displayTemplate, string displayPlugin, string settingsShapeName) { //IContentQuery<HighlightsItemPart, LocalizationPartRecord> parts; var items = _contentManager .Query(VersionOptions.Published, "HighlightsItem") .Join <HighlightsItemPartRecord>() .Where <HighlightsItemPartRecord>(e => e.HighlightsGroupPartRecordId == groupId) .OrderBy(o => o.ItemOrder); var shapeList = new List <dynamic>(); var i = 0; foreach (var item in items.List()) { var itemPart = item.As <HighlightsItemPart>(); itemPart.GroupShapeName = settingsShapeName; itemPart.GroupDisplayTemplate = displayTemplate; itemPart.GroupDisplayPlugin = displayPlugin; var shape = _contentManager.BuildDisplay(item, displayTemplate.ToString()); //shape.Index = i; //shape.ParentShapeName = settingsShapeName; shapeList.Add(shape); i++; } return(shapeList); }
static void Main(string[] args) { DisplayTemplate.Header("Lambda Expressions"); List <int> numbers = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // Print even numbers in the list. foreach (int number in numbers) { if (number % 2 == 0) { Console.Write(number + " "); } } Console.WriteLine(); // Above method fits in one line, but it is still combination of foreach and if. // We can use FindAll method of List in combination with delegate. foreach (int number in numbers.FindAll(delegate(int number) { return(number % 2 == 0); })) { Console.Write(number + " "); } Console.WriteLine(); // Note that name of variable in foreach, which is 'number', can be either same or different from the name of variable in delegate. // delegate is a little confusing and hard to remember. To make it short, let's use Lambda Expression. foreach (int number in numbers.FindAll(number => number % 2 == 0)) { Console.Write(number + " "); } Console.WriteLine(); DisplayTemplate.Footer(); }
/// <summary> /// Binds the form. /// </summary> private void BindForm() { // Bind Meta classes MetaClass catalogEntry = MetaClass.Load(CatalogContext.MetaDataContext, "CatalogEntry"); MetaClassList.Items.Clear(); if (catalogEntry != null) { MetaClassCollection metaClasses = catalogEntry.ChildClasses; foreach (MetaClass metaClass in metaClasses) { MetaClassList.Items.Add(new ListItem(metaClass.FriendlyName, metaClass.Id.ToString())); } MetaClassList.DataBind(); } // Bind Templates TemplateDto templates = DictionaryManager.GetTemplateDto(); if (templates.main_Templates.Count > 0) { DataView view = templates.main_Templates.DefaultView; view.RowFilter = "TemplateType = 'entry'"; DisplayTemplate.DataSource = view; DisplayTemplate.DataBind(); } if (CatalogEntryId > 0) { if (_CatalogEntryDto.CatalogEntry.Count > 0) { Name.Text = _CatalogEntryDto.CatalogEntry[0].Name; AvailableFrom.Value = ManagementHelper.GetUserDateTime(_CatalogEntryDto.CatalogEntry[0].StartDate); ExpiresOn.Value = ManagementHelper.GetUserDateTime(_CatalogEntryDto.CatalogEntry[0].EndDate); CodeText.Text = _CatalogEntryDto.CatalogEntry[0].Code; IsActive.IsSelected = _CatalogEntryDto.CatalogEntry[0].IsActive; ManagementHelper.SelectListItem(DisplayTemplate, _CatalogEntryDto.CatalogEntry[0].TemplateName); ManagementHelper.SelectListItem(MetaClassList, _CatalogEntryDto.CatalogEntry[0].MetaClassId); // Bind Sort order foreach (CatalogRelationDto.NodeEntryRelationRow row in _CatalogRelationDto.NodeEntryRelation) { if (row.CatalogEntryId == _CatalogEntryDto.CatalogEntry[0].CatalogEntryId && row.CatalogId == this.ParentCatalogId && row.CatalogNodeId == this.ParentCatalogNodeId) { SortOrder.Text = row.SortOrder.ToString(); } } } } else { this.AvailableFrom.Value = ManagementHelper.GetUserDateTime(DateTime.UtcNow); this.ExpiresOn.Value = ManagementHelper.GetUserDateTime(DateTime.UtcNow).AddYears(1); } }
public async Task <IHtmlContent> InvokeDisplay(ContextualizedHelpers helpers, ModelExpression expression) { if (DisplayTemplate == null) { return(new HtmlString(string.Empty)); } return(await DisplayTemplate.Invoke(expression, this, helpers)); }
/// <summary> /// Loads the specified node uid. /// </summary> /// <param name="NodeUid">The node uid.</param> /// <param name="ControlUid">The control uid.</param> void IPropertyPage.Load(string NodeUid, string ControlUid) { ControlSettings settings = new ControlSettings(); DynamicNode dNode = PageDocument.Current.DynamicNodes.LoadByUID(NodeUid); if (dNode != null) { settings = dNode.GetSettings(NodeUid); } else { settings = PageDocument.Current.StaticNode.Controls[NodeUid]; } // Bind templates DisplayTemplate.Items.Clear(); DisplayTemplate.Items.Add(new ListItem("(use default)", "")); TemplateDto templates = DictionaryManager.GetTemplateDto(); if (templates.main_Templates.Count > 0) { DataView view = templates.main_Templates.DefaultView; view.RowFilter = "TemplateType = 'menu'"; foreach (DataRowView row in view) { DisplayTemplate.Items.Add(new ListItem(row["FriendlyName"].ToString(), row["Name"].ToString())); } DisplayTemplate.DataBind(); } string selectedMember = String.Empty; if (settings != null && settings.Params != null) { Param prm = settings.Params; if ((prm["DisplayTemplate"] != null) && (prm["DisplayTemplate"] is string)) { CommonHelper.SelectListItem(DisplayTemplate, prm["DisplayTemplate"].ToString()); } if ((prm["DataSource"] != null) && (prm["DataSource"] is string)) { CommonHelper.SelectListItem(DataSourceList, prm["DataSource"].ToString()); } if ((prm["DataMember"] != null) && (prm["DataMember"] is string)) { selectedMember = prm["DataMember"].ToString(); } } BindSourceMembers(selectedMember); }
public async Task <IHtmlContent> InvokeDisplay(object o, ContextualizedHelpers helpers, string overridePrefix = null) { if (DisplayTemplate == null) { return(new HtmlString(string.Empty)); } return(await DisplayTemplate.Invoke( new ModelExpression(combinePrefixes(AdditionalPrefix, For.Name), For.ModelExplorer.GetExplorerForModel(o)), this, helpers, overridePrefix)); }
public async Task <IHtmlContent> InvokeDisplay(object o, string prefix, ContextualizedHelpers helpers) { if (DisplayTemplate == null) { return(new HtmlString(string.Empty)); } //await PrerenderInLineColumnTemplates(o, prefix, helpers); return(await DisplayTemplate.Invoke( new ModelExpression(prefix, For.ModelExplorer.GetExplorerForModel(o)), this, helpers)); }
/// <summary> /// Binds the form. /// </summary> private void BindForm() { // Bind Meta classes MetaClass catalogNode = MetaClass.Load(CatalogContext.MetaDataContext, "CatalogNode"); MetaClassList.Items.Clear(); if (catalogNode != null) { MetaClassCollection metaClasses = catalogNode.ChildClasses; foreach (MetaClass metaClass in metaClasses) { MetaClassList.Items.Add(new ListItem(metaClass.FriendlyName, metaClass.Id.ToString())); } MetaClassList.DataBind(); } // Bind Templates TemplateDto templates = DictionaryManager.GetTemplateDto(); if (templates.main_Templates.Count > 0) { DataView view = templates.main_Templates.DefaultView; view.RowFilter = "TemplateType = 'node'"; DisplayTemplate.DataSource = view; DisplayTemplate.DataBind(); } if (CatalogNodeId > 0) { if (_CatalogNodeDto.CatalogNode.Count > 0) { Name.Text = _CatalogNodeDto.CatalogNode[0].Name; AvailableFrom.Value = ManagementHelper.GetUserDateTime(_CatalogNodeDto.CatalogNode[0].StartDate); ExpiresOn.Value = ManagementHelper.GetUserDateTime(_CatalogNodeDto.CatalogNode[0].EndDate); CodeText.Text = _CatalogNodeDto.CatalogNode[0].Code; SortOrder.Text = _CatalogNodeDto.CatalogNode[0].SortOrder.ToString(); IsCatalogNodeActive.IsSelected = _CatalogNodeDto.CatalogNode[0].IsActive; ManagementHelper.SelectListItem(DisplayTemplate, _CatalogNodeDto.CatalogNode[0].TemplateName); ManagementHelper.SelectListItem(MetaClassList, _CatalogNodeDto.CatalogNode[0].MetaClassId); } } else { this.AvailableFrom.Value = DateTime.Now; this.ExpiresOn.Value = DateTime.Now.AddYears(1); this.SortOrder.Text = "0"; } }
static void Main(string[] args) { DisplayTemplate.Header("Multi-Threading Programming"); int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; string[] flowers = { "Jasmine", "Rose", "Sunflower", "Lotus", "Lily" }; Thread numberThread = new Thread(new ParameterizedThreadStart(printNumbers)); Thread flowerThread = new Thread(new ParameterizedThreadStart(printFlowers)); numberThread.Start(numbers); flowerThread.Start(flowers); DisplayTemplate.Footer(); }
public override IEnumerable <DisplayTemplate> GetDisplayTemplates() { var displayTemplates = new DisplayTemplate[] { new CategoryDisplayTemplate { Id = ProductTemplateNameConstants.Category, Localizations = { ["sv-SE"] = { Name = "Kategori" }, ["en-US"] = { Name = "Category" } } }, new ProductDisplayTemplate { Id = ProductTemplateNameConstants.Product, Localizations = { ["sv-SE"] = { Name = "Produkt" }, ["en-US"] = { Name = "Product" } }, UseVariantUrl = true }, new ProductDisplayTemplate { Id = ProductTemplateNameConstants.ProductWithVariantList, Localizations = { ["sv-SE"] = { Name = "Produkt med variantlista" }, ["en-US"] = { Name = "Product with variant list" } } } }; return(displayTemplates); }
/// <summary> /// Loads the specified node uid. /// </summary> /// <param name="NodeUid">The node uid.</param> /// <param name="ControlUid">The control uid.</param> void IPropertyPage.Load(string NodeUid, string ControlUid) { ControlSettings settings = new ControlSettings(); DynamicNode dNode = PageDocument.Current.DynamicNodes.LoadByUID(NodeUid); if (dNode != null) { settings = dNode.GetSettings(NodeUid); } // Bind Meta Types // Bind Meta classes // MetaDataContext.Current = CatalogContext.MetaDataContext; MetaClass catalogEntry = MetaClass.Load(CatalogContext.MetaDataContext, "CatalogEntry"); MetaClassList.Items.Clear(); if (catalogEntry != null) { MetaClassCollection metaClasses = catalogEntry.ChildClasses; foreach (MetaClass metaClass in metaClasses) { MetaClassList.Items.Add(new ListItem(metaClass.FriendlyName, metaClass.Name)); } MetaClassList.DataBind(); } // Bind templates DisplayTemplate.Items.Clear(); DisplayTemplate.Items.Add(new ListItem("(use default)", "")); TemplateDto templates = DictionaryManager.GetTemplateDto(); if (templates.main_Templates.Count > 0) { DataView view = templates.main_Templates.DefaultView; view.RowFilter = "TemplateType = 'search-index'"; foreach (DataRowView row in view) { DisplayTemplate.Items.Add(new ListItem(row["FriendlyName"].ToString(), row["Name"].ToString())); } DisplayTemplate.DataBind(); } // Bind Types EntryTypeList.Items.Clear(); EntryTypeList.Items.Add(new ListItem(EntryType.Product, EntryType.Product)); EntryTypeList.Items.Add(new ListItem(EntryType.Package, EntryType.Package)); EntryTypeList.Items.Add(new ListItem(EntryType.Bundle, EntryType.Bundle)); EntryTypeList.Items.Add(new ListItem(EntryType.DynamicPackage, EntryType.DynamicPackage)); EntryTypeList.Items.Add(new ListItem(EntryType.Variation, EntryType.Variation)); EntryTypeList.DataBind(); // Bind catalogs CatalogList.Items.Clear(); CatalogDto catalogs = CatalogContext.Current.GetCatalogDto(CMSContext.Current.SiteId); if (catalogs.Catalog.Count > 0) { foreach (CatalogDto.CatalogRow row in catalogs.Catalog) { if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime) { CatalogList.Items.Add(new ListItem(row.Name, row.Name)); } } CatalogList.DataBind(); } //Bind Depositories this.ddlDepository.DataSource = Enum.GetNames(typeof(NWTD.InfoManager.Depository)); this.ddlDepository.DataBind(); if (settings != null && settings.Params != null) { Param prm = settings.Params; CommonHelper.LoadTextBox(settings, "NodeCode", NodeCode); CommonHelper.LoadTextBox(settings, "RecordsPerPage", NumberOfRecords); /* * CommonHelper.LoadTextBox(settings, "FTSPhrase", FTSPhrase); * CommonHelper.LoadTextBox(settings, "AdvancedFTSPhrase", AdvancedFTSPhrase); * CommonHelper.LoadTextBox(settings, "MetaSQLClause", MetaSQLClause); * CommonHelper.LoadTextBox(settings, "SQLClause", SQLClause); * */ if ((prm["DisplayTemplate"] != null) && (prm["DisplayTemplate"] is string)) { CommonHelper.SelectListItem(DisplayTemplate, prm["DisplayTemplate"].ToString()); } CommonHelper.SelectList(settings, "Catalogs", CatalogList); CommonHelper.SelectList(settings, "EntryClasses", MetaClassList); CommonHelper.SelectList(settings, "EntryTypes", EntryTypeList); // Orderby if ((prm["OrderBy"] != null) && (prm["OrderBy"] is string)) { string orderBy = prm["OrderBy"].ToString(); bool isDesc = orderBy.Contains("DESC"); string listOrderBy = orderBy.Replace(" DESC", ""); listOrderBy = listOrderBy.Replace(" ASC", ""); CommonHelper.SelectListItem(OrderByList, listOrderBy); if (!String.IsNullOrEmpty(OrderByList.SelectedValue)) { if (OrderByList.SelectedValue == "custom") { OrderBy.Text = orderBy; } else { OrderDesc.Checked = isDesc; } } } if (prm[DEPOSITORY_KEY] == null) { prm[DEPOSITORY_KEY] = NWTD.InfoManager.Depository.NWTD.ToString(); } this.ddlDepository.SelectedValue = settings.Params[DEPOSITORY_KEY].ToString(); } }
/** * Creates and returns the visual and spoken response with shouldEndSession flag * * @param title * title for the companion application home card * @param output * output content for speech and companion application home card * @param shouldEndSession * should the session be closed * @return SpeechletResponse spoken and visual response for the given input */ private SpeechletResponse BuildSpeechletResponse(string title, string output, bool shouldEndSession) { // Create the Simple card content. SimpleCard card = new SimpleCard(); card.Title = String.Format("SessionSpeechlet - {0}", title); card.Content = String.Format("SessionSpeechlet - {0}", output); // Create the plain text output. PlainTextOutputSpeech speech = new PlainTextOutputSpeech(); speech.Text = output; /* Create a directive for Echo Show (example) * This can be separeted so it can be easier to create * a Show Directive where you can only need to write * the important information */ IList <Directive> listDirectiveTest = new List <Directive>(); DisplayRenderTemplateDirective directiveTest = new DisplayRenderTemplateDirective(); DisplayTemplate templateTest = new DisplayTemplate(); DisplayImage backgroundTest = new DisplayImage(); DisplayImage imageTest = new DisplayImage(); IList <DisplayImageSource> backgroundSourcesTest = new List <DisplayImageSource>(); IList <DisplayImageSource> imageSourcesTest = new List <DisplayImageSource>(); DisplayImageSource backgroundSource = new DisplayImageSource(); backgroundSource.Url = "URL for the background image - must be secure (https)"; DisplayImageSource imageSource = new DisplayImageSource(); imageSource.Url = "URL for the main image - must be secure (https)"; backgroundSourcesTest.Add(backgroundSource); imageSourcesTest.Add(imageSource); backgroundTest.ContentDescription = "Description for the background image"; backgroundTest.Sources = backgroundSourcesTest; imageTest.ContentDescription = "Description for the main image"; imageTest.Sources = imageSourcesTest; TextContent textContentTest = new TextContent(); TextField primaryContentTest = new TextField(); TextField secondaryContentTest = new TextField(); TextField tertiaryContentTest = new TextField(); primaryContentTest.Text = "Primary Text (could be formatted)"; primaryContentTest.Type = TextField.TextTypeEnum.RichText; secondaryContentTest.Text = "Secondary Text (could be formatted)"; secondaryContentTest.Type = TextField.TextTypeEnum.RichText; tertiaryContentTest.Text = "Tertiary Text (could be formatted)"; tertiaryContentTest.Type = TextField.TextTypeEnum.RichText; textContentTest.PrimaryText = primaryContentTest; textContentTest.SecondaryText = secondaryContentTest; textContentTest.TertiaryText = tertiaryContentTest; templateTest.Title = "Hello, this is a Test"; templateTest.BackButton = DisplayTemplate.ButtonStateEnum.HIDDEN; templateTest.BackgroundImage = backgroundTest; templateTest.Image = imageTest; templateTest.Type = "BodyTemplate2"; templateTest.Token = ""; templateTest.TextContent = textContentTest; directiveTest.Template = templateTest; listDirectiveTest.Add(directiveTest); // Create the speechlet response. SpeechletResponse response = new SpeechletResponse(); response.ShouldEndSession = shouldEndSession; response.OutputSpeech = speech; response.Card = card; response.Directives = listDirectiveTest; return(response); }
static void Main(string[] args) { // Instead of copying and pasting the header and footer of program all the time // Using a template which is defined in DisplayTemplate class of Templates namespace // This reduces redundant writing of code. To use this class, add Templates project as a reference. DisplayTemplate.Header("Fun With Collections"); // There are many in-built collections. // Use Generic collections to avoid issues. // List is a dynamic array. The size can increase. Console.WriteLine("Integer type List Example"); List <int> intArr = new List <int>(); for (int i = 0; i < 10; i++) { intArr.Add(i); } intArr.ForEach(num => Console.Write(num + " ")); // List can iterate over elements and use lambda expression. Console.WriteLine(); intArr.RemoveAt(5); intArr.ForEach(num => Console.Write(num + " ")); Console.WriteLine("\n"); // You can also make a General list. This list contains int, string and double. List <object> genArr = new List <object>(); genArr.Add(21); genArr.Add("Mark"); genArr.Add(0.5); Console.WriteLine("General List Example"); genArr.ForEach(num => Console.WriteLine(num + " : " + num.GetType())); Console.WriteLine(); // An example of Stack Stack <int> stack = new Stack <int>(); stack.Push(1); stack.Push(2); stack.Push(3); Console.WriteLine("Stack Example"); Console.WriteLine(stack.Pop()); Console.WriteLine(stack.Peek()); Console.WriteLine(); // An example of Queue Queue <int> queue = new Queue <int>(); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); Console.WriteLine("Queue Example"); Console.WriteLine(queue.Dequeue()); Console.WriteLine(queue.Peek()); Console.WriteLine(); // An example of Dictionary. Dictionary is a key-value pair. Key must be unique. Console.WriteLine("Dictionary Example"); Dictionary <int, string> courses = new Dictionary <int, string>() { [101] = "Math", [102] = "Science" }; courses.Add(103, "Computers"); courses.Add(104, "History"); // Iterate using keys foreach (int key in courses.Keys) { Console.WriteLine(key + " : " + courses[key]); } Console.WriteLine(); DisplayTemplate.Footer(); }
/// <summary> /// Loads the specified node uid. /// </summary> /// <param name="NodeUid">The node uid.</param> /// <param name="ControlUid">The control uid.</param> void IPropertyPage.Load(string NodeUid, string ControlUid) { ControlSettings settings = new ControlSettings(); DynamicNode dNode = PageDocument.Current.DynamicNodes.LoadByUID(NodeUid); if (dNode != null) { settings = dNode.GetSettings(NodeUid); } // Bind templates DisplayTemplate.Items.Clear(); DisplayTemplate.Items.Add(new ListItem("(use default)", "")); TemplateDto templates = DictionaryManager.GetTemplateDto(); if (templates.main_Templates.Count > 0) { DataView view = templates.main_Templates.DefaultView; view.RowFilter = "TemplateType = 'entry'"; foreach (DataRowView row in view) { DisplayTemplate.Items.Add(new ListItem(row["FriendlyName"].ToString(), row["Name"].ToString())); } DisplayTemplate.DataBind(); } // Bind catalogs CatalogList.Items.Clear(); CatalogList.Items.Add(new ListItem("(use default)", "")); CatalogDto catalogs = CatalogContext.Current.GetCatalogDto(CMSContext.Current.SiteId); if (catalogs.Catalog.Count > 0) { foreach (CatalogDto.CatalogRow row in catalogs.Catalog) { if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime) { CatalogList.Items.Add(new ListItem(row.Name, row.Name)); } } CatalogList.DataBind(); } //Bind Depositories this.ddlDepository.DataSource = Enum.GetNames(typeof(NWTD.InfoManager.Depository)); this.ddlDepository.DataBind(); if (settings != null && settings.Params != null) { Param prm = settings.Params; if ((prm["NodeCode"] != null) && (prm["NodeCode"] is string)) { NodeCode.Text = prm["NodeCode"].ToString(); } if ((prm["EntryCode"] != null) && (prm["EntryCode"] is string)) { EntryCode.Text = prm["EntryCode"].ToString(); } if ((prm["DisplayTemplate"] != null) && (prm["DisplayTemplate"] is string)) { CommonHelper.SelectListItem(DisplayTemplate, prm["DisplayTemplate"].ToString()); } if ((prm["CatalogName"] != null) && (prm["CatalogName"] is string)) { CommonHelper.SelectListItem(CatalogList, prm["CatalogName"].ToString()); } if (prm[DEPOSITORY_KEY] == null) { prm[DEPOSITORY_KEY] = NWTD.InfoManager.Depository.NWTD.ToString(); } this.ddlDepository.SelectedValue = settings.Params[DEPOSITORY_KEY].ToString(); } }
static void Main(string[] args) { DisplayTemplate.Header("Language Integrated Queries (LINQ)"); DisplayTemplate.Header("LINQ to Objects"); string[] games = { "Skyrim", "Uncharted 4", "The Last Of Us", "The Witcher III", "Control" }; IEnumerable <string> subset = from game in games where game.Contains(" ") orderby game select game; foreach (string game in subset) { Console.WriteLine(game); } Console.WriteLine(); // Another way is to use extensions subset = games.Where(game => game.Contains("The")).OrderBy(game => game).Select(game => game); foreach (string game in subset) { Console.WriteLine(game); } Console.WriteLine(); // Instead of using IEnumerable, we can also use var var sorted = games.OrderBy(game => game).Select(game => game); foreach (string game in sorted) { Console.WriteLine(game); } Console.WriteLine(); // LINQ queries are dynamic. Which means, there is no need to define LINQ queries again and again. games[1] = "God Of War"; foreach (string game in sorted) { Console.WriteLine(game); } Console.WriteLine(); // Data from LINQ queries can be stored in a collection. int[] numbers = { 1, 2, 5, 7, 8, 23, 12, 45, 76, 32, 124, 6, 53, 4, 34 }; int[] evenNumbers = numbers.Where(number => number % 2 == 0).OrderBy(number => - number).Select(number => number).ToArray <int>(); foreach (int number in evenNumbers) { Console.Write(number + " "); } Console.WriteLine(); // Note that values do not change after storing in a collection. numbers[1] = 25; foreach (int number in evenNumbers) { Console.Write(number + " "); } Console.WriteLine("\n"); // LINQ queries over objects of custom classes List <Student> students = new List <Student>() { new Student(101, "Mark", 10), new Student(105, "John", 12), new Student(104, "Jack", 10), new Student(102, "Simon", 12), new Student(103, "Phillip", 10), }; Student[] tenthGradeStudents = students.Where(student => student.Grade == 10).OrderBy(student => student.RollNumber).Select(student => student).ToArray <Student>(); foreach (Student student in tenthGradeStudents) { Console.WriteLine(student.Name); } Console.WriteLine(); // In above example, I am creating array of Student, even though I am just printing names. // This is very inefficient as Student array takes a lot more space than a string array. // A better way is to retrieve only required data. string[] tenthGradeStudentsNames = students.Where(student => student.Grade == 10).OrderBy(student => student.RollNumber).Select(student => student.Name).ToArray <string>(); foreach (string student in tenthGradeStudentsNames) { Console.WriteLine(student); } Console.WriteLine(); DisplayTemplate.Footer(); }