I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
Introduction
The Set operators in LINQ refer to the query operations that produce a result set. The result is based on the presence or absence of the equivalent elements that are present within the same or separate collection. The Distinct, Union, Intersect, and Except clauses are classified as the Set operators. The Distinct clause removes duplicate values from a collection.The syntax of the Distinct clause is:
For C#
public static IEnumerable<T> Distinct<T>( this IEnumerabIe<T> source);
The Union clause returns the union of two sets. The result elements are the unique elements that are common in the two sets.
The syntax of the Union clause is:
For C#
public static IEnumerabIe<T> Union<T>( this IEnumerabIe<T> source1, IEnumerabIe<T> source2);
The Intersect clause returns the set intersection. The elements appear in each of the two collections.
The syntax of the Intersect clause is:
For C#
public static IEnumerabIe<T> Intersect<T>( this IEnumerabIe<T> source1, IEnumerabIe<T> source2);
The Except clause returns the set difference. The result of the Except clause returns the elements of one collection that do not appear in the second collection.
The syntax of the Except clause is:
For C#
public static 1Enumerable<T> Except<T>( this 1Enumerable<T> sourcel, IEnumerab1e<T> source2);
lets take an simple example
Source Code<form id="form1" runat="server">
<div>
</div>
<asp:ListBox ID="ListBox1" runat="server" Height="137px" Width="221px">
</asp:ListBox>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="common word" />
</form>
Code behind
protected void Button1_Click(object sender, EventArgs e)
{
string[] fruits = { "apple", "mango", "banana" };
string[] wds = { "my world", "mango", "operation" };
var common = fruits.Intersect(wds);
ListBox1.Items.Add("common in both array");
foreach (var item in common)
{
ListBox1.Items.Add(item);
}
}
Code Generate the following output
Comments
Post a Comment