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 }); }
When you have gone through the above static memory allocation concept, it is clear that the static memory allocation major disadvantages. To overcome those disadvantages dynamic memory allocation is used. That is the reason why dynamic memory allocation has many advantages over static memory allocation .
When main memory is allocated statically it cannot be altered during the execution of program. When main memory is allocated dynamically it can be altered during the execution of program as per the user wish. The length of dynamically allocated memory either can be decreased or increased. This is the major advantage of dynamic memory allocation over static memory allocation.
Suppose user wishes to enter elements of an array or a list one by one just after allocating memory and he may stop at any point then definitely it is not possible by means of static memory allocation. So the dynamic memory allocation certainly has an advantage in this case over static memory allocation. Such dynamically created list is called as linked list.
In case of dynamically created lists insertions and deletions can be done very easily just by the manipulation of addresses whereas in case of statically allocated memory insertions and deletions lead to more number of movements and wastage of memory.
In case of statically allocated memory there is every chance of “overflow” during insertions in the lists, whereas in case of dynamically allocated memory it does not come into picture unless otherwise unavailability of main memory.
For some liner data structures like STACK and QUEUE, dynamic memory allocation proves very much appropriate because the length of such data structure is not fixed. They may increase or decrease dynamically that is during the execution of program. Similarly non-linear data structures need recursive definitions of “struct” data type, so the need of dynamic memory allocation.
Once you go through the implementation of dynamic data structure the advantages of the same will be clear.
When main memory is allocated statically it cannot be altered during the execution of program. When main memory is allocated dynamically it can be altered during the execution of program as per the user wish. The length of dynamically allocated memory either can be decreased or increased. This is the major advantage of dynamic memory allocation over static memory allocation.
Suppose user wishes to enter elements of an array or a list one by one just after allocating memory and he may stop at any point then definitely it is not possible by means of static memory allocation. So the dynamic memory allocation certainly has an advantage in this case over static memory allocation. Such dynamically created list is called as linked list.
In case of dynamically created lists insertions and deletions can be done very easily just by the manipulation of addresses whereas in case of statically allocated memory insertions and deletions lead to more number of movements and wastage of memory.
In case of statically allocated memory there is every chance of “overflow” during insertions in the lists, whereas in case of dynamically allocated memory it does not come into picture unless otherwise unavailability of main memory.
For some liner data structures like STACK and QUEUE, dynamic memory allocation proves very much appropriate because the length of such data structure is not fixed. They may increase or decrease dynamically that is during the execution of program. Similarly non-linear data structures need recursive definitions of “struct” data type, so the need of dynamic memory allocation.
Once you go through the implementation of dynamic data structure the advantages of the same will be clear.
Comments
Post a Comment