Friday, July 15, 2011

C# 3.5 Features

C# 3.5 feature:-

Implicit Type Variable:-
This is the new feature of .NET where the data type is determined at debug time.
Eg. As below:-
//implicitly typed variables

var i = 10;
var d = 10.5;
var str = "India";

var arr = new int[]{ 1, 2, 3 };

foreach (var item in arr)
{
Console.WriteLine(item.ToString());
}
Console.ReadLine();

Restriction of this data type is it can not be null or uninitialized
//Restriction

var j;
var k = null;

Object Initializer:-
Object initializer is concept where value of the property can be initialize at the time of creating object.
public class Point
{
public int X { get; set; }
public int Y { get; set; }
}

//Object Initializer is used to initialize the value of peroperty as below
Point p = new Point {X = 10, Y = 20 };
//the older version of initializing values of property
//p.X = 10;
//p.Y = 20;

//Collection Initializer
List intList = new List(){1,2,3,4,5,6};
//Old way to initialize value
//intList.Add(1);
//intList.Add(2);
//intList.Add(3);
//intList.Add(4);
//intList.Add(5);
//intList.Add(6);
// following the same thing can be achieved using object initializer

List intPoint = new List()
{
new Point{X=1,Y=2},
new Point{X=4,Y=4}
};

Anonymous Type:-
Anonymous type is concept where without explicitly defined the type first you can initialize the value. For e g:- we don’t have customer table but by using following code we can initialize the value of customer. The complier on the fly create an data type to hold customer object.
//Anonymous type
var customer = new { customerId = 1, Name = "Microsoft" };
var customer1 = new { customerId = 2, Name = "IBM" };
var customer2 = new { Id = 2, Name = "IBM" };

Console.WriteLine(customer.customerId);
Console.WriteLine(customer.Name);

Lamda Expression:-
A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.
All lambda expressions use the lambda operator =>, which is read as "goes to". The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. The lambda expression x => x * x is read "x goes to x times x."
public delegate int MyDelegate(int args);
public delegate int Calculator(int args1,int args2);
public delegate void SimpleDelegate();

//Following is the way to create delegate
MyDelegate md = delegate(int x)
{
return x * x;
};

//Following is the way to create delegate using Lamda Expression
MyDelegate md = x => x * x;
Console.WriteLine(md(5));
Console.ReadLine();

//Following is the way to create delegate using Lamda Expression having two perameter
Calculator calc = (x, y) => x + y;
Console.WriteLine(calc(5,25));

//Following is the way to create delegate using Lamda Expression having multiple statment
SimpleDelegate sd = () => { Console.WriteLine("Hello World"); Console.ReadLine(); };
sd();
Console.WriteLine(sd());

Extenssion Mehtods:-
Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type. For eg. You don’t have RemoveNonNumberic method in string. If you want to extent the string class to have RemoveNonNumberic function then you need to do following:-
1) Create a static class implementing the functionality of Removing non numeric value.
public static class StringExtension
{
public static string RemoveNonNumeric(this string str)
{
StringBuilder strBldr = new StringBuilder();

for (int i = 0; i < str.Length; i++)
{
if (char.IsNumber(str[i]))
{
strBldr.Append(str[i]);
}
}

return strBldr.ToString();
}
}
2) Incorporate the class as below:-
Using StringExtension;
3) The string function can be used as below:-
string phone = "+91-022-42042042";
Console.WriteLine(phone.RemoveNonNumeric());
Console.ReadLine();

Thursday, July 14, 2011

SharePoint 2010 Prerequisite

Prerequisite of SPS2010

Operating System:-
Developer can install it on window 7 & Vista 64 bit m/c.
Production server should be install in windows 2008 server SP2 or later 64 bit m/c. It can be install in window 2008 R2.

SQL Server Environment:-
* 64 bit SQL Server 2008 R2
* 64 bit SQL Server 2008 SP1
* 64 but SQL Server 2005 SP3
Prefer SqlServer 2008R2 to install.

IIS:-
IIS 7.0 is required.

Additional Component:-
SPS2010 works on .Net freamwork 3.5.
ADO.NET data services
Windows workflow foundation.
Windows Identity Foundation.

Hardware Requirment:-

WebServer,AppServer, Single Server:-
Processor:64 bit, four core
RAM: 4GB for developer or evaluation. 8GB for production.

DataBase Server:-
Processor:64 bit
RAM: 8GB small, 16 GB for production

hard disk: 80GB

Wednesday, January 19, 2011

Site Page Vs Application Page

Site pages are customized pages and are saved in to content database.Application pages are generic pages which will be used by all the sites in a site collection & stored on file system.