Contents tagged with .Net Framework
-
C# 7 - Return multiple values from methods
It was a long-awaited feature to return multiple values from a method. Developers used collection variables such as Array, ArrayList or Generic List to return multiple values from methods. Now with Visual Studio 2017 and C# 7, you can easily return multiple values with the help of Tuples.
In this article, I am going to explain how tuples can be used in C# 7 onwards to return multiple values.
Consider the following code from the console application. The method GetDivisionResults accepts two parameters namely number and divisor and returns two integers that are quotient and remainder.
static void Main(string[] args)
{
int number = 17;
int devisor = 5;
var result = GetDivisionResults(17, 5);
Console.WriteLine("Quotient is " + result.Item1);
Console.WriteLine("Remainder is " + result.Item2);
} -
Create an offline installer for Visual Studio 2017
Since Visual Studio 2017 is released, I wanted to try it as usual. But I found, there is no ISO available for Visual Studio 2017. But there is a beautiful guide available that explains how to create an offline installer for Visual Studio. You can find the document in the below link
-
Securing sections in Web.Config
For ASP.Net applications, developers usually store lots of configuration data in the Web.Config, some of such settings can contain secured information such as connection strings, email settings, proxy settings etc. Storing credential information in Web.Config as plain text is a threat as this could lead to leak the information. Though the web server will not render web.config files to the visitors, you need to see there could be users, such as system administrators, back up operators, etc who have access to your server’s file system. Exposing secured information for such users is a threat and you need to protect your configuration data. The solution is to encrypt the sections in Web.Config and thankfully ASP.Net offers out of the box support for encrypting and decrypting the connection string placed inside Web.Config.
In this article I am going to demonstrate, how to encrypt/decrypt the connection string section in Web.Config, you can follow the same concepts to encrypt any other section in web.config. For the purpose of the article, I created an ASP.Net empty web application and added a default.aspx file. The project in solution explorer looks as follows.
-
Change default language settings in Visual Studio 2012
The first thing you need to do after the installation of Visual Studio 2012 is to choose the IDE preferences. Once you select your preferred collection of settings, the IDE will always choose dialogs and other options according to your selection. Nowadays developer’s needs to work with different programming environments and due to this, developers might need to reset the default settings. In this article, I am going to demonstrate how you can change the default settings in Visual Studio 2012.
-
Extension methods in .Net framework
Recently one of my friend asked me about extension method. Though it was introduced in .Net framework 3.0, lots of people are not using this or not aware of the power of extension methods. So I decided to write a blog post about this to give an introduction to the extension methods.