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 this tutorial we will learn basic structure of the c# program . A structure can hold multiple things such as namespaces , main method ,classes etc.
The basic structure of the c# program is
using System;
//import namespaces here
namespace ConsoleApplication4
{
//create new namespace her also a namespace can contain sub namespace,classes,delegates etc
class Program
{
//class start here . A class can hold data member and member function.
static void Main(string[] args)
{
}
}
}
If you want to create a new c# application in visual studio then follow some steps for creating C# console application.
Step-1: Open visual studio
Step-2: Select file->new->project
Step-3: New Window will open , In Left pane you can select your language and right pane you can select application(console application)
Step-4: After selection (left pane-->VB and right pane -->Console application)
Step-5: now at time you can design your first c# application
If you want to write and read something like "hello world" on/from console window then you should use Console class. This class provide static method for reading and writing . lets take an example if you want to write something on console window then use
Console.WriteLine("hello world");
Similarly if you want to read something from keyboard then use
string n = Console.ReadLine();
here is the complete code.
what is a namespace : The namespace is used to organize your code and is a collection of classes, interface, structs, enums and delegates.
Main method: main method is the entry point into your application.
Output
The basic structure of the c# program is
using System;
//import namespaces here
namespace ConsoleApplication4
{
//create new namespace her also a namespace can contain sub namespace,classes,delegates etc
class Program
{
//class start here . A class can hold data member and member function.
static void Main(string[] args)
{
}
}
}
If you want to create a new c# application in visual studio then follow some steps for creating C# console application.
Step-1: Open visual studio
Step-2: Select file->new->project
Step-3: New Window will open , In Left pane you can select your language and right pane you can select application(console application)
Step-4: After selection (left pane-->VB and right pane -->Console application)
Step-5: now at time you can design your first c# application
If you want to write and read something like "hello world" on/from console window then you should use Console class. This class provide static method for reading and writing . lets take an example if you want to write something on console window then use
Console.WriteLine("hello world");
Similarly if you want to read something from keyboard then use
string n = Console.ReadLine();
here is the complete code.
using System;
//import nameapces here
namespace ConsoleApplication4
{
//create new namespace her also a namespace can contain sub namespace,classes,delegates etc
class Program
{
//class start here . A class can hold data member and member function.
static void Main(string[] args)
{
Console.WriteLine("hello world");
string n = Console.ReadLine();
Console.ReadKey();
}
}
}
here is the first line define the declaration of the namespace.//import nameapces here
namespace ConsoleApplication4
{
//create new namespace her also a namespace can contain sub namespace,classes,delegates etc
class Program
{
//class start here . A class can hold data member and member function.
static void Main(string[] args)
{
Console.WriteLine("hello world");
string n = Console.ReadLine();
Console.ReadKey();
}
}
}
what is a namespace : The namespace is used to organize your code and is a collection of classes, interface, structs, enums and delegates.
Main method: main method is the entry point into your application.
Output
Comments
Post a Comment