Wednesday, January 23, 2013

ReSharper always reminds us how pampered we .NET developers are


class Program
{
 static void Main(string[] args)
 {
  var list = new List<Person>();
  
  // ReSharper suggests to convert this code...
  var people = Mate.Create<Person>(list);
  
  // ...to the following code. .NET can infer the type, thus <Person> can be removed:
  var people = Mate.Create(list);
 }
}

public static class Mate
{
 public static IEnumerable<T> Create<T>(IEnumerable<T> list)
 {
  var ee = new ExcelExport<T>();

  return list;
 }
}

public class Person
{
   
}

public class ExcelExport<T>
{       
}

No comments:

Post a Comment