Visual Studio provides a project template for working with Angular and .Net Core.
ng g @angular/core:standalone
ng generate @angular/core:standalone schematics can be used to convert Module based Angular project to Stand alone.
Visual Studio provides a project template for working with Angular and .Net Core.
ng g @angular/core:standalone
ng generate @angular/core:standalone schematics can be used to convert Module based Angular project to Stand alone.
.Net Model View Controller (MVC) is a Server Side Web Application Technology. It Comprises of Model, which is the object oriented representation of data by way of POCO classes. View represents the user interface. Controller represents the user Interaction. There are other alternatives like Razor Pages for creating Server Side .Net applications. Mastering MVC will go a long way in learning other technologies like .Net Web API(with Controllers).
.Net MVC application can be developed either using Visual Studio, Visual Studio Code C# Dev Kit or .Net CLI. I am going develop MVC using Visual Studio. using Microsoft.AspNetCore.Mvc;
namespace MVCShalvin.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
}
}
Here there are Index and Privacy Action Methods which returns View.
namespace MVCShalvin.Models
{
public class Faculty
{
public string Name { get; set; }
public string Specialization { get; set; }
}
}
using Microsoft.AspNetCore.Mvc;
using MVCShalvin.Models;
namespace MVCShalvin.Controllers
{
public class HomeController : Controller
{
Faculty faculty = new Faculty
{
Name = "Shalvin P D",
Specialization = ".Net"
};
public IActionResult Index()
{
return View(faculty);
}
}
}
Here the faculty object is passed as a parameter to View.
@model MVCShalvin.Models.Faculty
<div>Hello @Model.Name specializing in @Model.Specialization</div>
C# is a popular cross platform programming language used to creating wide ranging of applications like Web, Desktop, or Mobile.
You can create a C# application using wide range of options like Visual Studio or Visual Studio Code.
Here I am concentrating on .Net CLI with Visual Studio Code.
.Net CLI (Command Line Interface) can be used to create and build .Net application.
dotnet new console -o HelloConsole
This command creates a console application within a folder called HelloConsole inside the current folder.
code . opens the current folder which comprises of the project in Visual Studio Code.
Console.WriteLine("Hello Shalvin P D");
Memory Variable
string name = "Shalvin P D";
Console.WriteLine("Hello, {0}", name);
Interpolation
string name = "Shalvin";
Console.WriteLine($"Hello {name}");
Multiple Memory Variable
string name = "Shalvin";
string location = "Kochi";
Console.WriteLine($"Hello {name}, located at {location}.");
Memory Variable Console.ReadLine
string name;
Console.WriteLine("Enter your Name: ");
name = Console.ReadLine();
Console.WriteLine($"Hello {name}");
Multiple String Memory Variables
string name, location;
Console.WriteLine("Enter your Name: ");
name = Console.ReadLine();
Console.WriteLine("Enter your Location: ");
location = Console.ReadLine();
Console.WriteLine($"Hello {name}, located at {location}.");
Integer Memory Variable
int i, j, res;
i = 23;
j = 45;
res = i + j;
Console.WriteLine(res);
Int32.Parse (Simple Calculator)
int i, j, res;
Console.WriteLine("Enter Value 1: ");
i = Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter Value 2: ");
j = Int32.Parse(Console.ReadLine());
res = i + j;
Console.WriteLine(res);
If Statement
string city;
Console.WriteLine("Enter the Name of the City: ");
city = Console.ReadLine();
if (city == "Kochi")
{
Console.WriteLine("Industrial Capital of Kerala");
}
If else
string city;
Console.WriteLine("Enter the Name of the City: ");
city = Console.ReadLine();
if (city == "Kochi")
{
Console.WriteLine("Industrial Capital of Kerala");
}
else
{
Console.WriteLine("I don't know");
}
Multiple else if
string city;
Console.WriteLine("Enter the Name of the City: ");
city = Console.ReadLine();
if (city == "Kochi")
{
Console.WriteLine("Industrial Capital of Kerala");
}
else if (city == "Trichur")
{
Console.WriteLine("Cultural Capital of India");
}
else if (city == "Trivandrum")
{
Console.WriteLine("Capital of Kerala");
}
else
{
Console.WriteLine("I don't know");
}
Functions
def hello():
print("Hello functions")
hello()
Functions with Parameters
def add(i, j):
return i + j
print(add(12, 23))
Exception Handling
try:
i = int(input("Enter value 1 : "))
j = int(input("Enter value 2 : "))
res = i / j
print(res)
except ValueError:
print("Invalid Input")
except ZeroDivisionError:
print("Cannot divide by zero")
def divide():
try:
i = int(input("Enter value 1 : "))
j = int(input("Enter value 2 : "))
res = i / j
print(res)
except ValueError:
print("Invalid Input")
except ZeroDivisionError:
print("Cannot divide by zero")
divide()
print("Hello Python")
Memory Variable
name = "Shalvin P D"
print("Hello ", name)
Multiple assignments
name, passion = "Shalvin", "IT"
print(f"{name} - {passion}")
input
name = input("Enter your name : ")
print("Hello ", name)
int()
i = int(input("Enter value 1 : "))
j = int(input("Enter value 2 : "))
res = i + j
print(res)
float()
i = float(input("Enter value 1 : "))
j = float(input("Enter value 2 : "))
res = i + j
print(res)
Lists
technologies = [".Net", "Python", "Angular"]
for tech in technologies:
print(tech)
Lists append()
technologies = [".Net", "Python", "Angular"]
technologies.append("C#")
for tech in technologies:
print(tech)
Lists remove()
technologies = [".Net", "Python", "Angular", "C#", "PHP"]
technologies.remove("PHP")
for tech in technologies:
print(tech)
Lists Concatenation
technologies1 = [".Net", "Python", "Angular", "C#"]
technologies2 = ["DevOps", "Jenkins"]
technologies = technologies1 + technologies2
for tech in technologies:
print(tech)
Dictionary
contact = {"name" : "Shalvin", "location": "Kochi"}
print(contact)
print(contact["name"])
print(f'{contact["name"]} : {contact["location"]}')
List of Dictionaries
contacts = [{"name" : "Shalvin", "location": "Kochi"},
{"name": "Praseed", "location": "UK"}]
print(contacts)
first_contact = contacts[0]
print(first_contact)
print(f"{first_contact['name']} - {first_contact['location']}")
print("Listing all contacts")
for contact in contacts:
print(f"{contact['name']} - {contact['location']}")
Blazor is a free and open-source web framework that enables developers to create web apps using C# and HTML developed by Microsoft. Previously creating such apps required the knowledge of JavaScript Libraries/Frameworks like Angular, React, VueJS, JQuery, etc. Now it is possible for .Net developers to use their familiar tools and language (C#) to create compelling UIs. Blazor has different variants like Blazor Server, Blazor Web Assembly, Blazor United aka Full Stack Blazor (.Net 8), etc. In this article we will be concentrating on Blazor Server.
Creational design patterns deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. They increase flexibility in deciding which objects need to be created for a given use case. Some of the most commonly used creational design patterns include:
Abstract Factory: Creates an instance of several families of classes.
Builder: Separates object construction from its representation, always creates the same type of object.
Factory Method: Creates an instance of several derived classes.
Prototype: A fully initialized instance to be copied or cloned.
Singleton: A class of which only a single instance can exist.
Abstract factory pattern: This pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.
Builder pattern: This pattern separates the construction of a complex object from its representation, allowing the same construction process to create various representations.
Factory method pattern: This pattern defines an interface for creating an object, but allows subclasses to alter the type of objects that will be created.
Prototype pattern: This pattern specifies the kind of objects to create using a prototypical instance, and creates new objects by copying this prototype.
Singleton pattern: This pattern ensures that a class has only one instance and provides a global point of access to it.
It's important to note that, the best pattern to use depends on the specific situation, and it's important to weigh the trade-offs between the different options before implementing one.