source
http://technet.microsoft.com/en-us/library/ms162234%28SQL.100%29.aspx
code
//Connect to the local, default instance of SQL Server.
{
Server srv = default(Server);
srv = new Server();
//Create a linked server.
LinkedServer lsrv = default(LinkedServer);
lsrv = new LinkedServer(srv, "OLEDBSRV");
//When the product name is SQL Server the remaining properties are
//not required to be set.
lsrv.ProductName = "SQL Server";
lsrv.Create();
}
why to use default(Server),?
-even if its like server asd = new asd(); it will still connect to the default instance!
why to use default(linkedserver)
-whats the point? we still specify the srv and provider and product!
default(...)is the default value operator. It evaluates to null for reference types, or the “zero” value for value types.There’s absolutely no point to it here… the variable is assigned a different value immediately. Here’s the equivalent, tidier code: