The params keyword in C#
Specifying the the C# params keyword as a function argument allows one to pass a variating number of arguments to the function. The type of the arguments should be specified preceding the params keyword. When calling the function, the arguments can be specified comma-delimited, or passwd in as a simple array. The arguments can be also omitted. When declaring a function, the params keyword should go last in the params list. No arguments are allowed after the params is specified. Also no two params are allowed in the declaration. Also notice the arguments can only be of same type only. You can specify generic object type, ut in this can you have to distinguish between arguments.
OpenFileDialog and SaveFileDialog
In C#.NET development environment, the common dialog windows for opening and saving files are represented by the OpenFileDialog and SaveFileDialog classes. The classes have much in common, so let's look at them together in this article.
Database Initialization Strategies in EF 6 Code-First
If you need to create database for your EF6 application you will need to think about initialization strategy. How to ensure the correct initialization of the database for the first time and also ensure it will not be re-created second time onwards? How to ensure it won't create a new database every time the ASP.NET Core application run? How can we deploy one database for a debug environment and another database for production environment? Entity Framework Does provide several strategies for database creation. They are called the database initialization strategies.
Read more: Database Initialization Strategies in EF 6 Code-First
What is Universal Windows Platform?
The UWP (Universal Windows Platform) is a unified platform for building and running apps on Windows 10 and Windows 10 Mobile.
UWP is the evolution of earlier technologies. So, with the release of Windows 8, a new architectural platform for applications was introduced - Windows Runtime (WinRT), which allowed running applications in the so-called Modern (Metro) mode on desktops and tablets. Then, with the release of Windows 8.1 and Windows Phone 8.1, this technology was developed - there were "universal applications" that could run immediately Windows 8.1 and WP8.1. And in July 2015, the new Windows 10 OS was officially released. It uses the UWP platform, which is an evolution of the Windows Runtime.
As the name of the platform suggests, it is universal - universal for all devices in the Windows 10 ecosystem. And these are ordinary destops, tablets, mobile devices, IoT (Internet of Things) devices, Xbox, Surface Hub devices. And a UWP app can work the same on all of these platforms as long as they have Windows 10 installed.
Using Ninject in C# ASP.NET MVC5 Projects
The IoC containers are used for dependency injection. There are many IoC containers, we use Ninject, as it is easy to use and understand. You can install the required package via NuGet. The package is called Ninject.MVC5
After installing the package, we can already use Ninject in the project. For example, let's change the constructor of the controller as follows:
using Ninject;
//.....................
public class HomeController : Controller
{
IRepository repo;
public HomeController()
{
IKernel ninjectKernel = new StandardKernel();
ninjectKernel.Bind<IRepository>().To<BookRepository>();
repo = ninjectKernel.Get<IRepository>();
}
public ActionResult Index()
{
return View(repo.List());
}
}