using System;
class HelloWorld
{
public static void Main()
{
Console.WriteLine("Hello World!");
}
}
csc HelloWorld.cs
HelloWorld.exe
A framework to work easily with database inside the code. It auto creates connections, and we don't need to take care about many things.
Framework that creates methods and views of CRUD.
A method that have not
A mechanism for communication between objects
This is a way to use some methods without the needy of the entire class.
It's similar to pointers in C/C++
A agreement/contract between publisher and subscriber
Determines the signature of the event handler method in subscriber
- Define a delegate and define an event based on that delegate
First way:
Public delegate void MethodNameEventHandler(object source, EventArgs args)
- Source: the class that is pusblishing/sending the event
- Args: any arguments we could pass
- In .NET there is a convention to name the delegate method as Name + EventHandler (
MethodNameEventHandler
)
Public event MethodNameEventHandler VideoEncoded;
Other (best) way:
Define a without args as parameters
public event EventHandler VideoEncoded;
Define a with args as parameters
public event EventHandler<EventArgs> VideoEncoded;
- The event. It's just a pointer to the events that we can define after.
- ○ The event has the same name of the eventHandler
- Raise the event
Protected virtual void OnEventName(){}
- The method that calls the event
- .NET suggestions that the event publisher methods should be protected, virtual and void, start with the word On and the name of the event (VideoEncoded)
We can see that it's not necessary to change the class that have the delegates, we can just put more and more events.
Lambda expression is anonymous function that can be used to create delegates or types of expression threes
As a way to see how it's possible, we can separate in steps the transformation of a normal function to a anonymous function, you can see a example below:
- First we normal function, that makes a filter of a list:
var list = new List<int>() {1, 2, 3, 4, 5, 6, 7, 8};
var filteredList = list.Where(
public bool filter(int x){
return x > 4;
}
);
-
Then, we can make some modifications to tranform to a anonymous function:
- The previous method would be executed only inside the
Where
, then we don't need thepublic
modificator - The
Where
already waits for a returnboolean
, then we don't need to specify the type of the return - The
Where
already waits for the typeint
of the parameter (according to the type of the list), then we don't need to specify that - The function would be executed at only one place, then we don't need to specify the name of the function
- We don't need the curly braces if the function has only one line
- if return is a boolean we don't need the word
return
- If we have only one parameter, we don't need to put the parentheses
- The final thing is put a arrow between the parameter and the function
- The previous method would be executed only inside the
var list = new List<int>() {1, 2, 3, 4, 5, 6, 7, 8};
var filteredList = list.Where(x => x > 4;);
- We can use a function without that beeing coupled with the class.
- That turns the function smaller
Web.config - used to define DLLs (including the versions) for our projects Package.config* - used to define the packages for Visual Studio
Web.config vs App.config
The choice of the configuration file name is determined by the hosting environment you choose for the service. If you are using IIS to host your service, use a Web.config file. If you are using any other hosting environment, use an App.config file.
TODO
@Html.Partial("ButtonBuy", new { text = "I'm modular", color = "red" });
It's possible to make Views and invoke inside them other pieces of code (like a button). That makes the code more modular and improve the speed of coding. There is a new way is using View Components through ASP .NET Core MVC with a benefit to be able to work with database.