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
If you want to remove first element from an array. First of all, fill array with some values.Create a list collection and fill it with array list. Remove first element using RemoveAt(0) method , here 0 is the first index of array. After remove, must resize array using Resize( ) method. Again pass resized list into array.Source Code
<form id="form1" runat="server"><asp:Button ID="Button1" runat="server" Text="Animal" Width="100px"
onclick="Button1_Click" ForeColor="Red" />
<div>
<asp:Label ID="Label1" runat="server" Text="Label" BackColor="Yellow"
BorderStyle="Solid" Font-Underline="True" ForeColor="Blue"></asp:Label>
</div>
</form>
CodeBehind Code
#region remove_first_indexprotected void Button1_Click(object sender, EventArgs e)
{
string[] animal = new string[]
{
"Cow",
"Monkey",
"Black buffalo",
"Donkey",
"Yak"
};
Label1.Text = "animal array.........<br />";
foreach (string s in animal)
{
Label1.Text += s + "<br />";
}
List<string> animallist = animal.ToList();
animallist.RemoveAt(0);
Array.Resize(ref animal, animal.Length - 1);
for (int i = 0; i < animal.Length; i++)
{
animal[i] = animallist[i];
}
foreach (string s in animal)
{
Label1.Text += s + "<br />";
}
}
#endregion
Comments
Post a Comment