"Knowledge has to be improved, challenged, and increased constantly, or it vanishes."

Archives

Archives / 2017 / March
  • 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);
             }

  • Develop SharePoint Add-In using SharePoint 2016 On Premise and Visual Studio


    In this article, I am going to explain how to create SharePoint hosted Add-In using Visual Studio and how to deploy this Add-In to SharePoint 2016 on premise version.

    Building a successful Add-in include two steps. First you need to author your Add-In using Visual Studio. Once you build your Add-in you need to deploy this Add-In to a SharePoint environment and test the Add-In. You can deploy the Add-In to SharePoint online or to the on-premise SharePoint. This article covers the deployment of Add-in to the On Premises version.

    Step 1: Create Your Add-In

    Open Visual Studio as administrator. From the Menu, select File -> New -> Project

    In the new Project Dialog box, from the left menu, expand Visual C#, then Office/SharePoint and choose SharePoint Add-in. Also you can use the search box in the top right corner to locate the Add-n Project template.

    clip_image002