Thursday, November 13, 2014

Visual Studio 2015

November 12, 2014 Microsoft open its door for Mac and Linux developer. Microsoft announce the availability of next version of Visual Studio. I believe it is the beginning of a new era and lots of amazing things to come.
 
High lights of .NET 2015 
  • .NET Core 5 is the modern, componentized framework that ships via NuGet. This means we can ship our own version of .NET framework with app and other apps cannot change our app behavior.

  • .NET Core CLR for Windows, Mac and Linux and it will be open source. Microsoft will be supporting it.

  • It will make RyuJit and the .NET GC open source and cross-platform compatible.

  • Visual Studio Community for students and open source developers.

  • Visual Studio 2015 and ASP.NET 5 will support JavaScript utility like gulp, grunt, bower and npm for front end developers.
Above all .NET Core Framework 4.6 and its references source will be available in GitHub. And there will be a new hub for Microsoft open source in GitHub(http://microsoft.github.io)

You can download Visual Studio 2015 Preview from here.

 
 

Thursday, November 6, 2014

Action and Func

Action and Func are the generic type delegates. Both are defined under System namespace. So in your program you do not need to define it.

Action
Encapsulate any types of method which match the following signature.
1. Has a void return type.
2. Has up to 16 parameters. All parameters in Action are defined as generic.

Action<string> act = new Action<string>(a.Function1);

Func
1. Has up to 17 parameters. All parameters in Action are defined as generic.
2. It has a return type.
3. Last parameter is always an output parameter. It is also implemented as generic so it can return any value.

Func<string string> fun = new Func<string string>(a.Function2);


Below are the compete codes

using System;
namespace TestDelegate
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("-Start program-");
            ABC a = new ABC();
            
            Action<string> act = new Action<string>(a.Function1);
            act.Invoke("Call by Action");

            Func<string string> fun = new Func<string string>(a.Function2);
            var result = fun.Invoke("Call by Func");
            Console.WriteLine(result.ToString());
            
            Console.ReadKey();
        }
    }

    class ABC
    {
        public void Function1(string s)
        {
            Console.WriteLine(s);
        }

        public string Function2(string s)
        {
            Console.WriteLine(s);
            return "I am returned from Function2";
        }
    }
}



Output:
-Start program-                    
Call by Action                       
Call by Func                         
I am returned from Function2


Happy coding...:)