The .NET Framework 3.5 Client Profile is a lightweight subset of the full .NET Framework 3.5 aimed to be deployed in Client machines. Therefore, it only have the assemblies that are commonly used on client boxes and does not contains any server or development related assemblies.
This framework subset weight just 27Mb against the 200Mb of the full framework.
You can get the bits from here: Microsoft .NET Framework 3.5 Client Profile (BETA)
It’s pretty easy, if you have installed the Visual Studio 2008 SP1 in the project properties you will find a checkbox that allows to target your application to the Client Profile subset.
Visual Studio will verify all the references and will add an exclamation icon on the references that are not available for the client subset, also when building the project, warnings will be displayed for the unavailable assemblies.
If you got the beta version of the Visual Studio SP1 you have to take in mind that the subset list (Client.xml) that Visual Studio uses to validate the references is out of synch from the actually included assemblies (VS generate warnings for some assemblies that really are in the Client Profile). To solve this issue, you may find useful the Justin Van Patten’s blog post: .NET Framework Client Profile.
This post is aimed to be a quick abstract for all the new C# language constructs introduced with the version 3.0.
By using var keyword to define a local (does not work at class level) variable is not needed to define its type, the compiler will infer it.
Examples:
var i = 0;
var intArr = new[] { 0, 1, 2, 3 };
Object’s properties can be initialized when creating the object and also the collection items.
Examples:
TextBox txt = new TextBox() { Text = "John", Width = 200 };
List<string> colorspaces = new List<string> {"RGB", "CMYK", "GreyScale", "B/W"};
By combining the previous two features (Implicitly typed variables and Object initializers) you can create anonymous types (statically typed, with no name used in the code).
Example:
var guy = new { FirstName = "John", LastName = "Doe" };
Console.WriteLine(guy.FirstName);
You can create properties with no need for a private member to store its value.
Examples:
public string Name { get; set; }
//read-only property
public byte Age { get; private set; }
By using the this keyword in a static method argument you can extend another class. You "injects" methods to an existing class from another one.
Example:
public static class ExtensionClass
{
//Extension method
public static byte ToGray(this Color c)
{
return (byte)(0.3 * c.R + 0.59 * c.G + 0.11 * c.B);
}
}
byte pixelGray = Color.Green.ToGray();
Lambda expressions are like pretty simple functions that takes input parameters and evaluates an expression.
Syntax:
(input parameters) => expression
Examples:
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int oddNumbers = numbers.Count(n => n % 2 == 1);
Console.WriteLine(oddNumbers.ToString());
Func<int, int> duplicate = number => number * 2;
Console.WriteLine(duplicate.Invoke(2).ToString());