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 }); }
In Type casting you can change types or convert one types of data into another type.In c#, Basically there are two types. First one implicit type casting and another one is explicit type casting. Both are very useful in c# application development like, in web application text box return by default text value and you want to take int type value then you must convert text to int.
Implicit type conversion - conversion is performed by c# compiler automatically with type-safe manner. Now lets to take an simple example here.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Double d;
int a=15;
d = a;
Console.Write(d.ToString());
Console.ReadKey();
}
}
}
Explicit type conversion - conversion is performed by programmer explicitly using the pre-defined functions. Suppose you want to change double type value into int type then must use pre-defined functions. This type of conversion is not safe. Lets take an simple example.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Double d = 3.14;
int a;
a = (int)d;
Console.Write(a.ToString());
Console.ReadKey();
}
}
}
Implicit type conversion - conversion is performed by c# compiler automatically with type-safe manner. Now lets to take an simple example here.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Double d;
int a=15;
d = a;
Console.Write(d.ToString());
Console.ReadKey();
}
}
}
Code Generate the following output
Explicit type conversion - conversion is performed by programmer explicitly using the pre-defined functions. Suppose you want to change double type value into int type then must use pre-defined functions. This type of conversion is not safe. Lets take an simple example.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Double d = 3.14;
int a;
a = (int)d;
Console.Write(a.ToString());
Console.ReadKey();
}
}
}
Code generate the following output
So there are various types available in c#, these are
ToBoolean : Convert one type to boolean type , if possible
ToByte : Convert one type to Byte type , if possible
etc.
Comments
Post a Comment