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 }); }
Its a concepts of inheritance, child class derived from base class or you can say, a class inherits property from other class known as derived class or child class.
This example cover, If you want to access base class method into child class, you should use base keyword for that. lets take an simple example to demonstrate of this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
abc obj = new abc();
Console.ReadKey();
}
public void getg()
{
Console.WriteLine("base class");
}
}
class abc : Program
{
public abc()
{
base.getg();
Console.WriteLine("Child class");
}
}
}
This example cover, If you want to access base class method into child class, you should use base keyword for that. lets take an simple example to demonstrate of this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
abc obj = new abc();
Console.ReadKey();
}
public void getg()
{
Console.WriteLine("base class");
}
}
class abc : Program
{
public abc()
{
base.getg();
Console.WriteLine("Child class");
}
}
}
Comments
Post a Comment