<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6185477160653879498</id><updated>2011-12-02T11:11:02.234+05:30</updated><category term='Title'/><category term='Information Architecture'/><category term='CSS'/><category term='Faceted Navigation'/><category term='Extension Methos'/><category term='Stylesheet'/><category term='SharePoint'/><category term='function pointer'/><category term='String'/><category term='Server'/><category term='FieldOffset'/><category term='Quick Launch'/><category term='Sort'/><category term='Static'/><category term='Collection'/><category term='Data Type'/><category term='Type Inference'/><category term='ASP.NET'/><category term='Reference Type'/><category term='C# 3.0'/><category term='Request'/><category term='2&apos;s Complement'/><category term='Browser'/><category term='Number'/><category term='Response'/><category term='StructLayout'/><category term='Document Library'/><category term='Web Part'/><category term='Sharepoint 2010'/><category term='List'/><category term='MOSS'/><category term='Client OM'/><category term='Value Type'/><category term='SP 2010'/><category term='Site'/><category term='delegate'/><category term='Silverlight'/><category term='.NET'/><title type='text'>.NET Lounge</title><subtitle type='html'>.NET-ites blog</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-6940457926163728587</id><published>2011-12-02T09:17:00.008+05:30</published><updated>2011-12-02T11:11:02.247+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Faceted Navigation'/><category scheme='http://www.blogger.com/atom/ns#' term='Sharepoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Information Architecture'/><title type='text'>Information Architecture and Faceted Navigation in SharePoint 2010</title><content type='html'>&lt;div&gt;SharePoint 2010 has new features included (such as Taxonomy, Document Sets) and search improvements (such as Refiners). This has brought in a whole lot of changes to the thought process related to information architecture.&lt;br /&gt;&lt;br /&gt;In MOSS 2007, we dealt with a linear guided navigation. SPS2010 improvements and new features introduced faceted navigation. It is also referred as faceted search or (free form) guided navigation. The faceted search presents users with a list of relevant suggestions for refining the search results by document type, site, author, modified date, tags etc.&lt;br /&gt;&lt;br /&gt;Information architecture is the key in designing the content management systems, knowledge management portals, e-Commerce sites and so on. Consider below points while deciding on Information architecture.&lt;br /&gt;&lt;br /&gt;• Content Roll up: Using Content Query web part, relevant and related content can be made available on content pages, document set welcome pages etc. Content Query web part has few improvements related to managed metadata (taxonomy) columns. Read &lt;a href="http://blogs.msdn.com/b/ecm/archive/2010/05/14/what-s-new-with-the-content-query-web-part.aspx"&gt;here&lt;/a&gt; what’s new in content query web part.&lt;br /&gt;• Refiners: This is a key to faceted search.  The refinement web part can be used to narrow the search results.&lt;br /&gt;• Extensibility of Search Web part: SPS 2010 has search web parts which can be extended. In MOSS 2007, these web parts are sealed. Scenario based search functionality can be extended and used on various pages, document set pages.&lt;br /&gt;&lt;br /&gt;I have listed here few of the points. There are many features in SPS 2010 which we can exploit for the better information architecture and good navigation providing better user experience.&lt;br /&gt;Few links about faceted search and information architecture.&lt;br /&gt;• &lt;a href="http://msdn.microsoft.com/en-us/magazine/hh456396.aspx"&gt;Building Information Architecture in SPS 2010&lt;/a&gt;&lt;br /&gt;• &lt;a href="http://www.alistapart.com/articles/design-patterns-faceted-navigation/"&gt;Faceted Navigation&lt;/a&gt;&lt;br /&gt;• &lt;a href="http://docs.com/8PI6"&gt;How Microsoft is leveraging the features in Infopedia and Microsoft Academy Mobile&lt;/a&gt;&lt;br /&gt;• &lt;a href="http://www.microsoft.com/casestudies/Case_Study_Detail.aspx?casestudyid=4000007395"&gt;Case Study: Microsoft Infopedia&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-6940457926163728587?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/6940457926163728587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=6940457926163728587' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/6940457926163728587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/6940457926163728587'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2011/12/information-architecture-and-faceted.html' title='Information Architecture and Faceted Navigation in SharePoint 2010'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-9049617152049696952</id><published>2011-08-02T18:41:00.000+05:30</published><updated>2011-08-02T19:01:50.625+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='Sharepoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='MOSS'/><title type='text'>SharePoint: Site Columns and Content Types</title><content type='html'>&lt;p&gt;There are various posts on the internet describing the site columns and content types. In this post I am co-relating these with concepts of objects and classes. This will help the developer visualize these concepts differently.&lt;/p&gt;  &lt;h4&gt;Content and Object&lt;/h4&gt;  &lt;p&gt;   &lt;p&gt;Object has data. Class provides the set of attributes to detail the object instances.&lt;/p&gt; &lt;/p&gt;  &lt;p&gt;Content is data. Content has two categories: Structured and Unstructured.&lt;/p&gt;  &lt;p&gt;   &lt;p&gt;Content comprises of documents and list items. Content does not include list or library itself. List or library helps user to organize the content.&lt;/p&gt; &lt;/p&gt;  &lt;p&gt;   &lt;p&gt;Structured content is the one which separates its storage from its display. e.g. List Items can be sorted/filtered and viewed in List web part or data row in a SQL data table.&lt;/p&gt; &lt;/p&gt;  &lt;p&gt;Unstructured content is the one which cannot be viewed separately the format in which they are stored. e.g. Word document cannot be viewed without the MS Office Word.&lt;/p&gt;  &lt;p&gt;​ &lt;/p&gt;  &lt;p&gt;Content type provides the set of attributes to define the metadata about content. The attributes are provided in the form of columns/fields in the list or at the site level.&lt;/p&gt;  &lt;h4&gt;Site Column&lt;/h4&gt;  &lt;p style="width: 436px; height: 5.77%"&gt;&lt;/p&gt;  &lt;p&gt;   &lt;p&gt;When the column is defined at site level, it is a site column. The site column is reusable across all lists and libraries in the site.&lt;/p&gt; &lt;/p&gt;  &lt;p&gt;This is very similar to have property declared in an interface and will be available across all objects implementing the interface.&lt;/p&gt;  &lt;h4&gt;Content Type&lt;/h4&gt;  &lt;p&gt;   &lt;p&gt;Content type is a set of site columns. The site column helps in describing the content. The content type can be used across the lists and libraries in the site. &lt;/p&gt; &lt;/p&gt; This is just like a complex data type. The data types/ classes has properties to describe the object.      &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-9049617152049696952?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/9049617152049696952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=9049617152049696952' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/9049617152049696952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/9049617152049696952'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2011/08/sharepoint-site-columns-and-content.html' title='SharePoint: Site Columns and Content Types'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-8621313342281520567</id><published>2011-04-13T17:36:00.003+05:30</published><updated>2011-04-13T18:05:40.906+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SP 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Sharepoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Document Library'/><category scheme='http://www.blogger.com/atom/ns#' term='MOSS'/><title type='text'>Document Library Creation with Specific Document Template Using Server Object Model</title><content type='html'>&lt;strong&gt;Introduction&lt;/strong&gt;: There is no way in SharePoint UI to create a document library with blank Excel/PowerPoint document template. But it is possible to create a document library with such document templates programmatically. &lt;p&gt;&lt;strong&gt;Technicalities&lt;/strong&gt;: &lt;br /&gt;I will first take you through the classes involved in development.&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;SPListCollection&lt;/li&gt;&lt;br /&gt;&lt;li&gt;SPListTemplateType&lt;/li&gt;&lt;br /&gt;&lt;li&gt;SPListTemplate&lt;/li&gt;&lt;br /&gt;&lt;li&gt;SPDocTemplate&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;em&gt;SPListCollection&lt;/em&gt; has &lt;em&gt;Add&lt;/em&gt; method with 7 overloads. Look for the method signatures &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistcollection_methods.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;We will concentrate on the following signature:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: rgb(0,51,153) thin solid; TEXT-ALIGN: left; BORDER-LEFT: rgb(0,51,153) thin solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: rgb(232,243,255); PADDING-LEFT: 5px; PADDING-RIGHT: 5px; DISPLAY: block; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; COLOR: rgb(0,0,128); FONT-SIZE: 10px; VERTICAL-ALIGN: top; BORDER-TOP: rgb(0,51,153) thin solid; FONT-WEIGHT: bolder; BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-TOP: 5px"&gt;&lt;br /&gt;public virtual Guid Add(&lt;br /&gt; string title,  //Title for the library&lt;br /&gt; string description,//Description about the library&lt;br /&gt; SPListTemplate template,//The list template. We are interested in Document Library.&lt;br /&gt; SPDocTemplate documentTemplate //The document template for library.e.g. Excel, Word or Powerpoint etc.&lt;br /&gt;)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;em&gt;SPListTemplateType&lt;/em&gt; is a enumeration. The enumeration has underlying integer values which match the Type attribute of ListTemplate element. Please visit &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splisttemplatetype.aspx"&gt;here&lt;/a&gt; for details.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;SPListTemplate&lt;/em&gt; represents the list definition or list template for the list. The list definition/template has the views and fields defined. &lt;em&gt;SPWeb.ListTemplates&lt;/em&gt; returns the list definitions for the web site. &lt;em&gt;SPSite.GetCustomListTemplates&lt;/em&gt; method returns the list template collection for the site collection. More &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splisttemplate.aspx"&gt;details&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;em&gt;SPDocTemplate&lt;/em&gt; represents the document template. Whenever we create a document library, it is created by using blank Word Document template. There are many document templates available in SharePoint 2010 OOB. The document templates have IDs. The ID is used to filter the document template collection presented by &lt;em&gt;SPWeb.DocTemplates&lt;/em&gt; property. Document Template IDs list follows:&lt;br /&gt;&lt;table style="border:1px solid black;text-align:center"&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;Document Template ID&lt;/td&gt;&lt;td&gt;Description&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;101&lt;/td&gt;&lt;td&gt;A blank Microsoft Word 97-2003 document.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;103&lt;/td&gt;&lt;td&gt;A blank Microsoft Excel 97-2003 document.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;104&lt;/td&gt;&lt;td&gt;A blank Microsoft PowerPoint 97-2003 document.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;105&lt;/td&gt;&lt;td&gt;A blank Microsoft basic page ASPX document.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;106&lt;/td&gt;&lt;td&gt;A blank Microsoft Web Part Page ASPX document.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;111&lt;/td&gt;&lt;td&gt;A basic Microsoft OneNote 2010 Notebook.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;121&lt;/td&gt;&lt;td&gt;A blank Microsoft Word document.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;122&lt;/td&gt;&lt;td&gt;A blank Microsoft Excel document.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;123&lt;/td&gt;&lt;td&gt;A blank Microsoft PowerPoint document.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;Code&lt;/strong&gt;:&lt;br /&gt;&lt;div style="BORDER-BOTTOM: rgb(0,51,153) thin solid; TEXT-ALIGN: left; BORDER-LEFT: rgb(0,51,153) thin solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: rgb(232,243,255); PADDING-LEFT: 5px; PADDING-RIGHT: 5px; DISPLAY: block; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; COLOR: rgb(0,0,128); FONT-SIZE: 10px; VERTICAL-ALIGN: top; BORDER-TOP: rgb(0,51,153) thin solid; FONT-WEIGHT: bolder; BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-TOP: 5px"&gt;&lt;br /&gt;using (SPSite site = new SPSite(serverUrl)) {&lt;br /&gt;   using (SPWeb web = site.OpenWeb()) {&lt;br /&gt;       SPListTemplate lstTemplate = web.ListTemplates["Document Library"];&lt;br /&gt;       SPDocTemplate docTemplate =(from SPDocTemplate dt in web.DocTemplates&lt;br /&gt;                                   where dt.Type == 122&lt;br /&gt;                                   select dt).FirstOrDefault();&lt;br /&gt;       Guid newLibID = &lt;br /&gt;         web.Lists.Add("Expense Claims", "Excel Expenses", lstTemplate, docTemplate);&lt;br /&gt;       SPDocumentLibrary newLib = web.Lists[newLibID] as SPDocumentLibrary;&lt;br /&gt;       newLib.OnQuickLaunch = true;&lt;br /&gt;       newLib.Update();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The code is for console application.(I know you are aware, just for clarity).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-8621313342281520567?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/8621313342281520567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=8621313342281520567' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/8621313342281520567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/8621313342281520567'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2011/04/document-library-creation-with-specific.html' title='Document Library Creation with Specific Document Template Using Server Object Model'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-7061724842213358538</id><published>2010-06-12T20:03:00.008+05:30</published><updated>2010-06-23T11:38:02.146+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Quick Launch'/><category scheme='http://www.blogger.com/atom/ns#' term='Sharepoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Part'/><title type='text'>Visibility Of Quick Launch Bar in Web Part Page of SP2010</title><content type='html'>&lt;div&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br /&gt;Web part pages are usually have only web part zones for web parts. They lack the quick launch navigation bar.&lt;br /&gt;In MOSS 2007, it was easy to have web part pages with quick launch by tweaking few lines in the page.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://2.bp.blogspot.com/_jzaues7bWBQ/TBOcHj6-nuI/AAAAAAAAAI8/z00E99Tf1Ac/s1600/img1.png"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 70px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5481896825155657442" border="0" alt="" src="http://2.bp.blogspot.com/_jzaues7bWBQ/TBOcHj6-nuI/AAAAAAAAAI8/z00E99Tf1Ac/s320/img1.png" /&gt;&lt;/a&gt;&lt;strong&gt;Team Site:&lt;/strong&gt;&lt;br /&gt;I used the same technique to show quick launch in web part page of SP Server 2010 publishing portal site. But it did not work for me. I googled for the same but was helpless. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;While working on some other site collection with a team site, I created a web part page &amp;amp; I found few additional CSS statements blocking the visibility of quick launch. I modified the line &amp;amp; wow, it worked there. I detailed the steps below for the same.&lt;br /&gt;Step I:&lt;br /&gt;Open the web part page in SharePoint Designer 2010. Comment the following lines.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://2.bp.blogspot.com/_jzaues7bWBQ/TBOdP6QxKeI/AAAAAAAAAJE/rkj92Om0dRk/s1600/img4.png"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 70px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5481898068103211490" border="0" alt="" src="http://2.bp.blogspot.com/_jzaues7bWBQ/TBOdP6QxKeI/AAAAAAAAAJE/rkj92Om0dRk/s320/img4.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Step II:&lt;br /&gt;Scroll up &amp;amp; locate the below shown lines.&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_jzaues7bWBQ/TBOd1CY1rUI/AAAAAAAAAJM/b4Mbeik4Lb0/s1600/img2.png"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 150px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5481898705939705154" border="0" alt="" src="http://3.bp.blogspot.com/_jzaues7bWBQ/TBOd1CY1rUI/AAAAAAAAAJM/b4Mbeik4Lb0/s320/img2.png" /&gt;&lt;/a&gt;&lt;br /&gt;Modify the line and set the display to ‘block’. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;That’s it. It worked for me. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Publishing Portal:&lt;/strong&gt;&lt;br /&gt;Then I used same technique at the publishing portal. But it did not work there. Again, I googled specific to Publishing Portal and again without relevant search results. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Then I started going through the page source and found that the CSS line, which I modified, is inside a VersionedContentPlaceHolder with an ID as “WebPartPageHideQLStyles”.&lt;br /&gt;&lt;/p&gt;&lt;a href="http://4.bp.blogspot.com/_jzaues7bWBQ/TBOkl9GbhCI/AAAAAAAAAJU/z6tE3mekkVo/s1600/img3.png"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 91px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5481906143403672610" border="0" alt="" src="http://4.bp.blogspot.com/_jzaues7bWBQ/TBOkl9GbhCI/AAAAAAAAAJU/z6tE3mekkVo/s320/img3.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I just commented it and it worked for me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-7061724842213358538?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/7061724842213358538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=7061724842213358538' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/7061724842213358538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/7061724842213358538'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2010/06/visibility-of-quick-launch-bar-in-web.html' title='Visibility Of Quick Launch Bar in Web Part Page of SP2010'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_jzaues7bWBQ/TBOcHj6-nuI/AAAAAAAAAI8/z00E99Tf1Ac/s72-c/img1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-2955729543516069066</id><published>2010-04-10T15:39:00.007+05:30</published><updated>2010-04-10T16:13:44.266+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Title'/><category scheme='http://www.blogger.com/atom/ns#' term='Sharepoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Client OM'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Site'/><title type='text'>SharePoint 2010 - Silverlight Client Object Model</title><content type='html'>&lt;strong&gt;Introduction&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;Recently, I worked on a project based on SharePoint 2010 Beta. While providing solution to client, we came across Silverlight Client Object Model (OM). Microsoft SharePoint Foundation 2010 has it as part of new Client API.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As it is new to us, few questions come to our mind: How to use it? What are the basic steps to make it work? What objects, properties and methods available for use? We dig out the answer for the same &amp;amp; made use of it in our project successfully. I’m not the only one to have such questions, hence this post. Hope this will help others also.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Silverlight Client OM helps us develop client-side solutions. To use Silverlight Client OM, one needs to refer two DLL files (assemblies) in the application: &lt;strong&gt;Microsoft.SharePoint.Client.Silverlight.dll&lt;/strong&gt; and &lt;strong&gt;Microsoft.SharePoint.Client.Silverlight.Runtime.dll&lt;/strong&gt;. The assemblies are located on SharePoint Server machine at “&lt;strong&gt;C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin&lt;/strong&gt;” folder.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To start coding, one must add “using” statement for &lt;em&gt;Microsoft.SharePoint.Client&lt;/em&gt; namespace. This core namespace provides types and members for working with SharePoint site-collection, sites, list data, and security. &lt;strong&gt;The Client API does not provide any admin objects or objects with scope higher than site collection&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;All client objects inherit &lt;em&gt;Microsoft.SharePoint.Client.ClientObject&lt;/em&gt; class &amp;amp; collections are inherited from &lt;em&gt;Microsoft.SharePoint.Client.ClientObjectCollection&lt;/em&gt; class.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Client Object and Value Object&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;All types, inheriting from &lt;em&gt;ClientObject&lt;/em&gt; class, are referred as client objects whereas types, inheriting from &lt;em&gt;ClientValueObject&lt;/em&gt; class, are value objects. Value objects have only properties &amp;amp; no methods. &lt;strong&gt;Do not conflict with Value Type concept of .NET Framework.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Scalar Property&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;Property, returning value object is referred as scalar property.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Frequently Used Types&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://2.bp.blogspot.com/_jzaues7bWBQ/S8BP0eT-YcI/AAAAAAAAAIU/PE48Pe5G93M/s1600/SilverlightClientOM.png"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 160px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5458450511281676738" border="0" alt="" src="http://2.bp.blogspot.com/_jzaues7bWBQ/S8BP0eT-YcI/AAAAAAAAAIU/PE48Pe5G93M/s320/SilverlightClientOM.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;All these types belong to “Microsoft.SharePoint.Client” namespace. “ClientContext” is the central object to gain access to Client OM. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Initializing Client Context&lt;/strong&gt;:&lt;/p&gt;&lt;p&gt;&lt;em&gt;ClientContext&lt;/em&gt; object requires the URL of site as a parameter to the constructor.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;e.g. &lt;em&gt;ClientContext context=new ClientContext(“http://www.somesite.com/”);&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Silverlight web part when host the Silverlight application, they pass the URL of site as a initialization parameter (InitParams) to the application.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Properties of ClientContext&lt;/strong&gt;: &lt;table&gt;&lt;br /&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align="middle"&gt;&lt;b&gt;Property&lt;/b&gt;&lt;/td&gt;&lt;td align="middle"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;Site&lt;/td&gt;&lt;td&gt;Retrieves site-collection associated with current context&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;Web&lt;/td&gt;&lt;td&gt;Retrieves context specific site.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;Current&lt;/td&gt;&lt;td&gt;Static property representing current context object.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;br /&gt;By using these properties, one can access client objects up to &lt;strong&gt;the site-collection level&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Methods of ClientContext&lt;/strong&gt;:&lt;br /&gt;Below are the three important methods of ClientContext.&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align="middle"&gt;&lt;b&gt;Method&lt;/b&gt;&lt;/td&gt;&lt;td align="middle"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Load&lt;/td&gt;&lt;td&gt;Used to load the query for the action.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;LoadQuery&lt;/td&gt;&lt;td&gt;Used to load the LinQ query &amp;amp; to perform queryable load. (see below)&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;ExecuteQueryAsync&lt;/td&gt;&lt;td&gt;Used to send the query to the server. This is an asynchronous operation.&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Client Objects do not have associated data until data retrieval is performed. Data retrieval is done using the Load &amp;amp; Execute methods of ClientContext&lt;/strong&gt;. Data retrieval can be executed in two ways: In-place load &amp;amp; queryable load. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;Queryable load uses “LoadQuery” method of context object &amp;amp; returns enumerable generic collection. It means, retrieved data goes to result collection. It does not load the data in the object itself. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;In-place load uses “Load” method of context &amp;amp; loads data to client objects. That means, retrieved data will be loaded to client objects. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;LinQ has two forms of data projection syntax: query syntax &amp;amp; method syntax. “LoadQuery” should be used when using query syntax. For method syntax, either of the load methods works. LinQ in Client OM is LinQ-to-Object. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;Once the query is loaded to the context, use ExecuteQueryAsync method to send the action query to server to get data. ExecuteQueryAsync has two parameters as delegate objects: &lt;em&gt;ClientRequestSucceededEventHandler&lt;/em&gt; &amp;amp; &lt;em&gt;ClientRequestFailedEventHandler&lt;/em&gt;. &lt;/p&gt;&lt;p&gt;&lt;em&gt;ClientRequestSucceededEventHandle&lt;/em&gt;r specifies the method to be executed after successful completion of ExecuteQueryAsync whereas &lt;em&gt;ClientRequestFailedEventHandler&lt;/em&gt; invokes method on failure of query execution.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Steps for Data Retrieval&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;1. Get ClientContext object.&lt;br /&gt;2. Specify the object to retrieve data using object model.&lt;br /&gt;3. Load the object either using in-place load or queryable load.&lt;br /&gt;4. Execute the query.&lt;br /&gt;5. Write code to process object in a method which will execute after successful invocation query.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Data Retrieval Example&lt;/strong&gt;:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="BORDER-BOTTOM: rgb(0,51,153) thin solid; TEXT-ALIGN: left; BORDER-LEFT: rgb(0,51,153) thin solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: rgb(232,243,255); PADDING-LEFT: 5px; PADDING-RIGHT: 5px; DISPLAY: block; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; COLOR: rgb(0,0,128); FONT-SIZE: 10px; VERTICAL-ALIGN: top; BORDER-TOP: rgb(0,51,153) thin solid; FONT-WEIGHT: bolder; BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-TOP: 5px"&gt;&lt;br /&gt;using System;&lt;br /&gt;using Microsoft.SharePoint.Client;&lt;br /&gt;&lt;br /&gt;namespace Example.Silverlight.ClientOM&lt;br /&gt;{&lt;br /&gt;ClientContext context;&lt;br /&gt;Web site;&lt;br /&gt;&lt;br /&gt;public MainPage()&lt;br /&gt;{&lt;br /&gt;InitializeComponent();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void Button_Click(object sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;context = ClientContext.Current;&lt;br /&gt;site = context.Web;&lt;br /&gt;&lt;br /&gt;context.Load(site,website=&amp;gt;website.Title);&lt;br /&gt;&lt;br /&gt;context.ExecuteQueryAsync(OnSuccess, null);&lt;br /&gt;}&lt;br /&gt;private void OnSuccess(object sender, ClientRequestSucceededEventArgs e)&lt;br /&gt;{&lt;br /&gt;MessageBox.Show(“Site Title:”+site.Title);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I know that this post requires few more examples. But due to time-constraint it is not possible. I'll update the post with few more samples and updates in few days. So visit again!!!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-2955729543516069066?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/2955729543516069066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=2955729543516069066' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2955729543516069066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2955729543516069066'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2010/04/sharepoint-2010-silverlight-client.html' title='SharePoint 2010 - Silverlight Client Object Model'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_jzaues7bWBQ/S8BP0eT-YcI/AAAAAAAAAIU/PE48Pe5G93M/s72-c/SilverlightClientOM.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-2350699782652597627</id><published>2009-11-20T16:26:00.004+05:30</published><updated>2009-11-20T16:58:24.999+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='List'/><category scheme='http://www.blogger.com/atom/ns#' term='Sort'/><category scheme='http://www.blogger.com/atom/ns#' term='Collection'/><title type='text'>Sorting List of Custom Objects</title><content type='html'>“System.Collections” and “System.Collections.Generic “ namespaces have classes for collections. Collection objects are the specialized objects which can hold multiple objects of other classes. Other classes also refer to collection classes along with non-collection classes. The two different namespaces have non-generic and generic versions of collection classes.&lt;br /&gt;My discussion is focusing on the &lt;em&gt;ArrayList&lt;/em&gt; collection class. This discussion also covers the generic version “List&amp;lt;T&amp;gt;"class.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is ArrayList?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;ArrayList&lt;/em&gt; is a non-generic collection class. Object of this class can hold list of homogeneous objects. Homogeneous objects means objects of any class (data type). This collection may not have necessarily objects of same type.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;ArrayList&lt;/em&gt; grows dynamically with addition of new objects. It does not have any fixed length. Initially, empty ArrayList object has capacity of 0 objects. As we add first object, the capacity grows to hold 4 objects. When we add the fifth object, it grows by double to hold 8 objects in it. ArrayList capacity doubles when its capacity is crossed.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;List&amp;lt;T&amp;gt;&lt;/em&gt; is just the generic version of &lt;em&gt;ArrayList&lt;/em&gt;. Generic collection object can have objects of same type only.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sorting:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;ArrayList&lt;/em&gt; and &lt;em&gt;List&lt;t&gt;&lt;t&gt;&lt;/em&gt;&lt;t&gt; have the sort method already implemented. This sort method works very well for primitive system data types (e.g. int, long etc.). But what about the user-defined types (viz. Class, Struct,Enum)? To order the objects you should know how to compare them. How to acquaint .NET Framework about comparing user-defined data types?&lt;br /&gt;&lt;div style="BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(0,51,153) thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: rgb(0,51,153) thin solid; COLOR: rgb(0,0,128); PADDING-TOP: 5px; BORDER-BOTTOM: rgb(0,51,153) thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(232,243,255); TEXT-ALIGN: left"&gt;&lt;br /&gt;public class Person&lt;br /&gt;{&lt;br /&gt;public string Name;&lt;br /&gt;public int Age;&lt;br /&gt;}&lt;br /&gt;List&amp;lt;person&amp;gt; plist=new &amp;lt;Person&amp;gt;();&lt;br /&gt;… //Add few person objects.&lt;br /&gt;plist.Sort(); &lt;/div&gt;&lt;br /&gt;Consider we’ve the list of person objects. How sorting will happen, based on Name or Age? What it’ll compare (name or age of persons)? Try it. &lt;p&gt;&lt;br /&gt;Comparison of Person object is possible only if we implement &lt;em&gt;IComparable&lt;/em&gt; or &lt;em&gt;IComparer&lt;/em&gt; interface. The &lt;em&gt;IComparable&lt;/em&gt; interface has single method, &lt;em&gt;CompareTo&lt;/em&gt;. See the code below with &lt;em&gt;IComparable&lt;/em&gt; interface implementation.&lt;br /&gt;&lt;div style="BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(0,51,153) thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: rgb(0,51,153) thin solid; COLOR: rgb(0,0,128); PADDING-TOP: 5px; BORDER-BOTTOM: rgb(0,51,153) thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(232,243,255); TEXT-ALIGN: left"&gt;&lt;br /&gt;public class Person : IComparable //Change it to IComparable&amp;lt;Person&amp;gt;&lt;br /&gt;{&lt;br /&gt;public string Name;&lt;br /&gt;public int Age;&lt;br /&gt;&lt;br /&gt;#region IComparable Members&lt;br /&gt;//Argument will be of Person type if IComparable&amp;lt;Person&amp;gt; is //implemented.&lt;br /&gt;public int CompareTo(Object obj)&lt;br /&gt;{&lt;br /&gt;Person p=obj as Person //Not required if generic IComparable implemented.&lt;br /&gt;return this.Name.CompareTo(p.Name);&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;em&gt;IComparable&lt;/em&gt; interface has generic variant, &lt;em&gt;IComparable&amp;lt;T&amp;gt;&lt;/em&gt; interface. The &lt;em&gt;CompareTo&lt;/em&gt; method of &lt;em&gt;IComparable&amp;lt;T&amp;gt;&lt;/em&gt; takes object of T as argument. So type-casting of argument is avoided. &lt;p&gt;&lt;br /&gt;Now it’ll sort the Person list with respect to their names. What if we’d like to have the sorting by Age? Change the code. &lt;p&gt;&lt;br /&gt;What if we’d like to have sorting by Age as well as by Name? Then &lt;em&gt;IComparable&lt;/em&gt; interface implementation is not sufficed. We’ve to create two implementations (classes) of &lt;em&gt;IComparer&lt;/em&gt; interface : &lt;em&gt;NameComparer&lt;/em&gt; and &lt;em&gt;AgeComparer&lt;/em&gt;. &lt;em&gt;IComparer&lt;/em&gt; interface has &lt;em&gt;Compare&lt;/em&gt; method accepting two objects. Cast the objects to appropriate type &amp;amp; then compare. Generic version of &lt;em&gt;IComparer&lt;/em&gt; is &lt;em&gt;IComparer&amp;lt;T&amp;gt;&lt;/em&gt; can be implemented in similar way. It avoids need of type-casting. &lt;p&gt;&lt;br /&gt;&lt;em&gt;NameComparer&lt;/em&gt; will have implementation of &lt;em&gt;Compare&lt;/em&gt; method based on Name whereas &lt;em&gt;AgeComparer&lt;/em&gt; will have implementation based on Age. These classes will not have any other code. &lt;p&gt;&lt;br /&gt;Sort method overload accepts object of &lt;em&gt;IComparer&lt;/em&gt; implementation (class) as argument. If our requirement is to compare by Age use object of AgeComparer, or else NameComparer for alphabetical sorting.&lt;br /&gt;&lt;div style="BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(0,51,153) thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: rgb(0,51,153) thin solid; COLOR: rgb(0,0,128); PADDING-TOP: 5px; BORDER-BOTTOM: rgb(0,51,153) thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(232,243,255); TEXT-ALIGN: left"&gt;&lt;br /&gt;public class NameComparer : IComparer&lt;br /&gt;{&lt;br /&gt;#region IComparer Members&lt;br /&gt;&lt;br /&gt;public int Compare(object x, object y)&lt;br /&gt;{&lt;br /&gt;Person p = x as Person;&lt;br /&gt;Person q = y as Person;&lt;br /&gt;return p.Name.CompareTo(q.Name);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#endregion&lt;br /&gt;}&lt;br /&gt;public class AgeComparer : IComparer&lt;br /&gt;{&lt;br /&gt;#region IComparer Members&lt;br /&gt;&lt;br /&gt;public int Compare(object x, object y)&lt;br /&gt;{&lt;br /&gt;Person p = x as Person;&lt;br /&gt;Person q = y as Person;&lt;br /&gt;return p.Age.CompareTo(q.Age);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#endregion&lt;br /&gt;}&lt;br /&gt;…&lt;br /&gt;plist.Sort(new AgeComparer());&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;That’s all folks!!! Reuse the .NET functionality.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-2350699782652597627?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/2350699782652597627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=2350699782652597627' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2350699782652597627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2350699782652597627'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2009/11/sorting-list-of-custom-objects.html' title='Sorting List of Custom Objects'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-2402929336201167875</id><published>2009-11-03T10:37:00.007+05:30</published><updated>2009-11-20T09:56:00.040+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Request'/><category scheme='http://www.blogger.com/atom/ns#' term='Response'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Response.Redirect and Server.Transfer</title><content type='html'>&lt;strong&gt;Response.Redirect:&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;Response is the object which accumulates the HTML/Javascript for the page requested. Each response has an associated Request object. Request object has the information about HTTP request headers and request body. Request body contains posted parameters.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I've used Web Developer helper tool to show you the details of HTTP Request &amp;amp; Response. HTTP request is comprised of HTTP command(e.g. GET,POST HEAD etc.) alongwith HTTP Headers (e.g. User-Agent) and the request body,if any. Request body appears only if user is posting some selections / values back to HTTP server. Diagram (1) shows you the details of HTTP Request.&lt;/p&gt;&lt;a href="http://3.bp.blogspot.com/_jzaues7bWBQ/Su-7A8h2cFI/AAAAAAAAAHw/5o7ASpHR1Zc/s1600-h/requestresponseGET.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5399740103163015250" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 320px; CURSOR: hand; HEIGHT: 250px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_jzaues7bWBQ/Su-7A8h2cFI/AAAAAAAAAHw/5o7ASpHR1Zc/s320/requestresponseGET.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;The image below shows the GET Request body.&lt;/p&gt;&lt;a href="http://2.bp.blogspot.com/_jzaues7bWBQ/Su-8O0yZQBI/AAAAAAAAAH4/FBSzjnYrx8o/s1600-h/requestresponseGET2.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5399741441114718226" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 320px; CURSOR: hand; HEIGHT: 263px; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_jzaues7bWBQ/Su-8O0yZQBI/AAAAAAAAAH4/FBSzjnYrx8o/s320/requestresponseGET2.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The images below show the POST request with Request body&lt;/p&gt;&lt;a href="http://4.bp.blogspot.com/_jzaues7bWBQ/Su-8t0qnX-I/AAAAAAAAAII/l61MuS0CyS8/s1600-h/requestresponsePOST1.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5399741973658034146" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 320px; CURSOR: hand; HEIGHT: 249px; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_jzaues7bWBQ/Su-8t0qnX-I/AAAAAAAAAII/l61MuS0CyS8/s320/requestresponsePOST1.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_jzaues7bWBQ/Su-8tj8-v3I/AAAAAAAAAIA/vfgcRD6XuSA/s1600-h/requestresponsePOST.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5399741969171660658" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 320px; CURSOR: hand; HEIGHT: 250px; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_jzaues7bWBQ/Su-8tj8-v3I/AAAAAAAAAIA/vfgcRD6XuSA/s320/requestresponsePOST.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If Response.Redirect is used to change the page to be shown, there is no access method available to access the posted values on second page. The reason : Response.Redirect involves round-trip to redirect the browser to new page. Browser redirection to new page has new request. Request body of first request of the round-trip lost unprocessed.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Response.Redirect helps to redirect to different server. Page on test.com can be redirected to google.com.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In essence, Response.Redirect involves one round-trip with two different requests. Response.Redirect loose the first-request body. Use Response.Redirect to redirect the browser to some page of different server. For same server, my suggestion is to use hyperlink or Server.Transfer.&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;Server.Transfer:&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;Server object represents the server processing request. Server.Transfer cannot transfer to the page of different server. Server.Transfer does not involve any round-trip. Request body is available to new page (of same server)as no round-trip involves.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-2402929336201167875?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/2402929336201167875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=2402929336201167875' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2402929336201167875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2402929336201167875'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2009/11/responseredirect-and-servertransfer.html' title='Response.Redirect and Server.Transfer'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_jzaues7bWBQ/Su-7A8h2cFI/AAAAAAAAAHw/5o7ASpHR1Zc/s72-c/requestresponseGET.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-4239923610061699771</id><published>2008-07-09T12:57:00.003+05:30</published><updated>2008-07-09T13:07:59.616+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Stylesheet'/><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><category scheme='http://www.blogger.com/atom/ns#' term='Browser'/><title type='text'>Dynamic Stylesheet Assignment Dependent on Browser</title><content type='html'>I've two stylesheets. One for Internet Explorer &amp;amp; other for other browsers. When the client is IE, the web page should have IE-specific stylesheet attached. For rest of the browsers, the web page must use the other stylesheet.&lt;br /&gt;&lt;b&gt;Demo&lt;/b&gt;: Get two stylesheets with body background set to two different colors.&lt;br /&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; display: block; font-weight: bolder; font-size: 10px; vertical-align: top; color: rgb(0, 0, 128); font-family: Verdana; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); text-align: left;"&gt;body&lt;br /&gt;{&lt;br /&gt;background-color:blue;&lt;br /&gt;}&lt;/div&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; display: block; font-weight: bolder; font-size: 10px; vertical-align: top; color: rgb(0, 0, 128); font-family: Verdana; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); text-align: left;"&gt;body&lt;br /&gt;{&lt;br /&gt;background-color:black;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;Add the following code to Page_Load event handler:&lt;br /&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; display: block; font-weight: bolder; font-size: 10px; vertical-align: top; color: rgb(0, 0, 128); font-family: Verdana; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); text-align: left;"&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;  {&lt;br /&gt;      HtmlLink lnk = new HtmlLink();&lt;br /&gt;      if (Request.Browser.Type.Contains("IE"))&lt;br /&gt;      {&lt;br /&gt;          lnk.Href = "~/StyleSheet.css";&lt;br /&gt;      }&lt;br /&gt;      else&lt;br /&gt;      {&lt;br /&gt;          lnk.Href = "~/StyleSheet2.css";&lt;br /&gt;      }&lt;br /&gt;      lnk.Attributes.Add("rel", "stylesheet");&lt;br /&gt;      lnk.Attributes.Add("type", "text/css");&lt;br /&gt;      this.Header.Controls.Add(lnk);&lt;br /&gt;  }&lt;/div&gt;Test with Internet Explorer &amp; some other browser like Mozilla, Opera etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-4239923610061699771?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/4239923610061699771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=4239923610061699771' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/4239923610061699771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/4239923610061699771'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/07/dynamic-stylesheet-assignment-dependent.html' title='Dynamic Stylesheet Assignment Dependent on Browser'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-2010658449204729527</id><published>2008-05-26T05:00:00.003+05:30</published><updated>2008-05-26T05:00:01.235+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='function pointer'/><category scheme='http://www.blogger.com/atom/ns#' term='delegate'/><title type='text'>Delegates in C#</title><content type='html'>Pointer is a variable, which stores address of some memory location. The memory location can be the storage for some value or beginning of function. When it points to function, it is function pointer. Function pointer has address of the function.&lt;br /&gt;&lt;br /&gt;Function pointers are not safe. In thousand lines of code, if we have to invoke the function using function pointer, we cannot assure that the pointer points to function without going through the code.&lt;br /&gt;We cannot ensure the number of parameters to the function or the order of parameters. Order of parameters refer to data types. What will happen if we invoked a function with function pointer &amp;amp; pointer is not pointing to function? What will happen if we invoked a function with function pointer &amp;amp; number of arguments are more or less passed? What will happen if we invoked a function with function pointer &amp;amp; order of parameters is wrong? (e.g. Function accepts &lt;span style="font-style: italic;"&gt;int&lt;/span&gt; first &amp;amp; we pass &lt;span style="font-style: italic;"&gt;string&lt;/span&gt; first.)&lt;br /&gt;&lt;br /&gt;In all cases, our application will crash. In essence, Function pointers are not type-safe.&lt;br /&gt;&lt;br /&gt;.NET has got a concept of delegates which are type-safe function pointers with ability to point to multiple functions. Delegates are declared in C# using keyword &lt;span style="font-style: italic;"&gt;delegate&lt;/span&gt;.&lt;br /&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; display: block; font-weight: bolder; font-size: 10px; vertical-align: top; color: rgb(0, 0, 128); font-family: Verdana; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); text-align: left;"&gt;public delegate void DisplayDelegate(string msg);&lt;/div&gt;&lt;br /&gt;Declaration of delegate is just like function declaration. That is, the delegate must be declared with return data type &amp;amp; parameters. Parameter names are not relevant.&lt;br /&gt;&lt;br /&gt;Internally, a class "DisplayDelegate" is generated which derives from &lt;span style="font-style: italic;"&gt;System.MulticastDelegate&lt;/span&gt;. &lt;span style="font-style: italic;"&gt;System.MulticastDelegate&lt;/span&gt; derives from &lt;span style="font-style: italic;"&gt;System.Delegate&lt;/span&gt;. &lt;span style="font-style: italic;"&gt;System.Delegate &lt;/span&gt;is the base class. One can create the object of "DisplayDelegate" class. The constructor accepts the function which has same signature as that of delegate declaration.&lt;br /&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; display: block; font-weight: bolder; font-size: 10px; vertical-align: top; color: rgb(0, 0, 128); font-family: Verdana; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); text-align: left;"&gt;using System;&lt;br /&gt;&lt;br /&gt;namespace DelegateDemo&lt;br /&gt;{&lt;br /&gt;public delegate void DisplayDelegate(string msg);&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;    static void Main(string[] args)&lt;br /&gt;    {&lt;br /&gt;        DisplayDelegate del = new DisplayDelegate(Show);&lt;br /&gt;        del("Hello, delegate!!!");&lt;br /&gt;        //Or del.Invoke("Hello, delegate!!!");&lt;br /&gt;    }&lt;br /&gt;    static void Show(string str)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine(str);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;To invoke function using delegate, use &lt;span style="font-style: italic;"&gt;Invoke&lt;/span&gt; function on delegate object with parameter values for the function. The function wrapped in delegate can be static or instance function.&lt;p&gt;Let's see, how delegates are type-safe? When one creates a delegate object, the delegate is aware of the parameters required. Wherever you call the function using delegate, compiler will not compile the program if,&lt;/p&gt;&lt;ul&gt;&lt;li&gt; function specified in constructor is not with appropriate function signature.&lt;/li&gt;&lt;li&gt;the number of parameters are less or more while invoking the function.&lt;/li&gt;&lt;li&gt;the order of parameters is not appropriate.&lt;/li&gt;&lt;/ul&gt;In essence, delegates are type-safe. One can catch the errors at compile-time only using delegates&lt;p&gt;&lt;/p&gt;A single delegate can have multiple functions. All functions must have same signature like delegate. Delegate invokes functions in FIFO(First-In,First-Out) order. If the function has return value, return value of last function invoked will be returned by delegate. Return values of all other functions are lost.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;System.Delegate&lt;/span&gt; class has two static methods &lt;span style="font-style: italic;"&gt;Combine&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;Remove&lt;/span&gt;. Use the methods to provide the delegate with multiple functions.&lt;br /&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; display: block; font-weight: bolder; font-size: 10px; vertical-align: top; color: rgb(0, 0, 128); font-family: Verdana; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); text-align: left;"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;&lt;br /&gt;namespace DelegateDemo&lt;br /&gt;{&lt;br /&gt;  public delegate void DisplayDelegate(string msg);&lt;br /&gt;  class Program&lt;br /&gt;  {&lt;br /&gt;      static void Main(string[] args)&lt;br /&gt;      {&lt;br /&gt;          DisplayDelegate del = new DisplayDelegate(Show);&lt;br /&gt;          DisplayDelegate del1 = new DisplayDelegate(Print);&lt;br /&gt;          del = (DisplayDelegate)Delegate.Combine(del, del1);&lt;br /&gt;          del("Hello,World!!!");&lt;br /&gt;          del = (DisplayDelegate)Delegate.Remove(del, del1);&lt;br /&gt;          del("Hi!!!");&lt;br /&gt;      }&lt;br /&gt;      static void Show(string str)&lt;br /&gt;      {&lt;br /&gt;          MessageBox.Show(str);&lt;br /&gt;      }&lt;br /&gt;      static void Print(string msg)&lt;br /&gt;      {&lt;br /&gt;          Console.WriteLine(msg);&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;System.Delegate&lt;/span&gt; has two properties &lt;span style="font-style: italic;"&gt;Method&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;Target&lt;/span&gt;. The derived class have these properties inherited. "Method" property gets the method represented by delegate. "Target" gets the instance/object on which the delegate operates. "Target" returns &lt;span style="font-style: italic;"&gt;null&lt;/span&gt; for static methods.&lt;br /&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; display: block; font-weight: bolder; font-size: 10px; vertical-align: top; color: rgb(0, 0, 128); font-family: Verdana; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); text-align: left;"&gt;static void Main(string[] args)&lt;br /&gt;      {&lt;br /&gt;          DisplayDelegate del = new DisplayDelegate(Show);&lt;br /&gt;          Console.WriteLine(del.Method.Name);&lt;br /&gt;          if(del.Target!=null)&lt;br /&gt;          Console.WriteLine(del.Target.ToString());&lt;br /&gt;      }&lt;/div&gt;&lt;br /&gt;If delegate has multiple functions, one can use &lt;span style="font-style: italic;"&gt;GetInvocationList&lt;/span&gt;  method of  &lt;span style="font-style: italic;"&gt;System.Delegate &lt;/span&gt;class to retrieve &lt;span style="font-style: italic;"&gt;System.Delegate[]&lt;/span&gt; array.&lt;br /&gt;&lt;br /&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; display: block; font-weight: bolder; font-size: 10px; vertical-align: top; color: rgb(0, 0, 128); font-family: Verdana; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); text-align: left;"&gt;static void Main(string[] args)&lt;br /&gt;      {&lt;br /&gt;          DisplayDelegate del = new DisplayDelegate(Show);&lt;br /&gt;          DisplayDelegate del1 = new DisplayDelegate(Print);&lt;br /&gt;          del = (DisplayDelegate)Delegate.Combine(del, del1);&lt;br /&gt;          foreach (DisplayDelegate minf in del.GetInvocationList())&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine(minf.Method.Name);&lt;br /&gt;          }&lt;br /&gt;      }&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-2010658449204729527?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/2010658449204729527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=2010658449204729527' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2010658449204729527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2010658449204729527'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/05/delegates-in-c.html' title='Delegates in C#'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-2618322572634157029</id><published>2008-05-21T05:00:00.004+05:30</published><updated>2008-05-21T09:41:11.369+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Number'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Type'/><category scheme='http://www.blogger.com/atom/ns#' term='2&apos;s Complement'/><title type='text'>Number Flip in numeric data types</title><content type='html'>Look at the code below. &lt;strong&gt;It prints -128 as output&lt;/strong&gt;. Oops!!! How?&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(0,51,153) thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: rgb(0,51,153) thin solid; COLOR: rgb(0,0,128); PADDING-TOP: 5px; BORDER-BOTTOM: rgb(0,51,153) thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(232,243,255); TEXT-ALIGN: left"&gt;using System;&lt;br /&gt;&lt;br /&gt;namespace NumberFlipDemo&lt;br /&gt;{&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;sbyte i = 127;&lt;br /&gt;i++;&lt;br /&gt;Console.WriteLine(i.ToString());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/div&gt;Let dig out the answer.&lt;br /&gt;If we look at carefully, signed byte has range from -128 to 127.&lt;br /&gt;Three methods to represent negative numbers:&lt;br /&gt;Signed Magnitude --&gt;Two representations for 0; -1 repsentated as 81.&lt;br /&gt;1's Complement --&gt; Two Representation for 0; -1 represented as FE.&lt;br /&gt;2'Complement --&gt; Single Representation for 0; -1 represented as FF.&lt;br /&gt;How negative numbers are represented in the machine? Let's check.See the code here.&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(0,51,153) thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: rgb(0,51,153) thin solid; COLOR: rgb(0,0,128); PADDING-TOP: 5px; BORDER-BOTTOM: rgb(0,51,153) thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(232,243,255); TEXT-ALIGN: left"&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;sbyte i = -1;&lt;br /&gt;Console.WriteLine(i.ToString("x"));&lt;br /&gt;//parameter "x" to ToString gives hex o/p.&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;Output is FF. Machine uses 2's complement.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How to compute 2's Complement representation?&lt;/strong&gt;Consider we want to represent -2 in 2's complement.&lt;br /&gt;Take binary representation of 2 i.e. 0000 0010. Complement all bits. Result is 1111 1101. Now add 1 to it. We will get 1111 1110 i.e. FE.&lt;br /&gt;&lt;br /&gt;To compute 2's complement representation of a number. First complement the bits of binary representation of the number absolute.( abs(-2)=2). Add bit 1 to the complemented bits. The result is 2's complement.&lt;br /&gt;Now back to our question. &lt;strong&gt;Why the above code snippet gives wrong o/p without any error&lt;/strong&gt;?&lt;br /&gt;Consider that size of integer is 2 bits. Hence range of numbers to be accomodated in integer data type is -2 to 1. Let put binary representation of all these numbers in a table.&lt;br /&gt;&lt;br /&gt;1--&gt; 01&lt;br /&gt;0--&gt; 00&lt;br /&gt;-1 --&gt; 11 (2's complement)&lt;br /&gt;-2 --&gt; 10 (2's complement)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now if my integer variable has a extreme positive value i.e. 1 e.g. i=1;&lt;br /&gt;Add 1 to i.&lt;br /&gt;&lt;br /&gt;i+1=1+1 =&gt;(01)+(01)=(10)=&gt; -2&lt;br /&gt;i has value 1 i.e. binary 01. Add 1 bit to it.See the result. It gives us 10 which is being binary representation for -2.&lt;br /&gt;&lt;br /&gt;In same fashion, number flips to -128 in case of signed byte. The theory is applicable to all whole number data types i.e. byte, sbyte,int, short, long.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Be careful while making choice of data type&lt;/strong&gt;!!! The theory applies to all programming lanaguages.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-2618322572634157029?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/2618322572634157029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=2618322572634157029' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2618322572634157029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/2618322572634157029'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/05/number-flip-in-numeric-data-types.html' title='Number Flip in numeric data types'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-557660006346481105</id><published>2008-05-20T05:00:00.003+05:30</published><updated>2008-05-20T05:01:00.537+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Extension Methos'/><category scheme='http://www.blogger.com/atom/ns#' term='Static'/><category scheme='http://www.blogger.com/atom/ns#' term='String'/><title type='text'>Extension Methods in C# 3.0</title><content type='html'>Developer code for assemblies. Compile it &amp;amp; publish it for client use. User of assembly may like to have some additional functionality in data types of the assembly. e.g &lt;span style="font-style: italic;"&gt;int&lt;/span&gt; or &lt;span style="font-style: italic;"&gt;Int32&lt;/span&gt; do not have function to convert integer to complex number. ComplexNumber is the new data type defined by user.&lt;br /&gt;&lt;br /&gt;Now with C# 3.0 has provided with the concept of extension methods. Extension methods enable us to extend the functionality of data types already defined. No source code of the assembly is available to modify &amp;amp; recompile the assembly. Still one can extend the data types functionality.&lt;br /&gt;&lt;br /&gt;Inheritance also provides capability to extend the functionality but the extended functionality is available only for derived classes &amp;amp; not to the base class. e.g Consider  I'd like to have  a &lt;span style="font-style: italic;"&gt;ToInt&lt;/span&gt; function in &lt;span style="font-style: italic;"&gt;String &lt;/span&gt;class&lt;span style="font-style: italic;"&gt;. &lt;/span&gt;If I use inheritance approach, I have to create new derived type. So I cannot use methods of derived type on my &lt;span style="font-style: italic;"&gt;String&lt;/span&gt; objects.&lt;br /&gt;&lt;br /&gt;Extension methods are written in static class. The method should also a static method. First parameter of the method must be of type being extended. The first parameter must have &lt;span style="font-style: italic;"&gt;this&lt;/span&gt; keyword before it.&lt;br /&gt;&lt;br /&gt;See the code below.&lt;br /&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; font-family: Verdana; font-size: 10px; font-weight: bolder; color: rgb(0, 0, 128); vertical-align: top; text-align: left; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); display: block;"&gt;public static class ExtensionInt&lt;br /&gt;{&lt;br /&gt; public static Complex ToComplex(this int val)&lt;br /&gt; {&lt;br /&gt;     Complex temp = new Complex();&lt;br /&gt;     temp.Real = val;&lt;br /&gt;     return temp;&lt;br /&gt; }&lt;br /&gt;}&lt;/div&gt;&lt;p&gt;&lt;span style="font-style: italic;"&gt;Complex&lt;/span&gt; is the type defined as follows:&lt;br /&gt;&lt;/p&gt;&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; font-family: Verdana; font-size: 10px; font-weight: bolder; color: rgb(0, 0, 128); vertical-align: top; text-align: left; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); display: block;"&gt;public class Complex&lt;br /&gt;{&lt;br /&gt; public int Real;&lt;br /&gt; public int Imag;&lt;br /&gt; public override string ToString()&lt;br /&gt; {&lt;br /&gt;     return (Real.ToString() + "+i" + Imag.ToString());&lt;br /&gt; }&lt;br /&gt;}&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;Use the method &lt;span style="font-style: italic;"&gt;ToComplex&lt;/span&gt; for &lt;span style="font-style: italic;"&gt;int&lt;/span&gt; or &lt;span style="font-style: italic;"&gt;Int32&lt;/span&gt;.&lt;div style="border: thin solid rgb(0, 51, 153); padding: 5px; font-family: Verdana; font-size: 10px; font-weight: bolder; color: rgb(0, 0, 128); vertical-align: top; text-align: left; white-space: pre; letter-spacing: normal; background-color: rgb(232, 243, 255); display: block;"&gt; static void Main(string[] args)&lt;br /&gt;  {&lt;br /&gt;      int i = 5;&lt;br /&gt;      Console.WriteLine(i.ToComplex().ToString());&lt;br /&gt;  }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Sealed classes can take advantage of extension methods. LINQ makes use of extension methods defined in &lt;span style="font-style: italic;"&gt;Enumerable&lt;/span&gt; static class. The class extends functionality of objects implementing &lt;span style="font-style: italic;"&gt;IEnumerable&lt;t&gt;&lt;/span&gt; interface. To use the extension methods from &lt;span style="font-style: italic;"&gt;Enumerable&lt;/span&gt; class refer the assembly &lt;span style="font-style: italic;"&gt;System.Core&lt;/span&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-557660006346481105?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/557660006346481105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=557660006346481105' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/557660006346481105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/557660006346481105'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/05/extension-methods-in-c-30.html' title='Extension Methods in C# 3.0'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-3155557920761942509</id><published>2008-05-19T05:00:00.004+05:30</published><updated>2008-05-19T09:54:04.218+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='C# 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Type Inference'/><title type='text'>Local Type Inference in C# 3.0</title><content type='html'>&lt;p&gt;C# 3.0 has new feature called "Local Type Inference". Type Inference lets compiler decide the data type of variable/object. Variable initializing data value helps compiler to decide the data type. C# 3.0 introduces new keywaord "var" to declare such variables. No explicit type declaration is required.&lt;/p&gt;&lt;p&gt;Local Type Inference has type inference only for local variables. One cannot declare class-/struct-level fields with keyword "var". "var" cannot act as return type for function and cannot appear in function parameter i.e. no "var" should be used in function signature.&lt;/p&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: rgb(0,51,153) thin solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(0,51,153) thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: rgb(0,51,153) thin solid; COLOR: rgb(0,0,128); PADDING-TOP: 5px; BORDER-BOTTOM: rgb(0,51,153) thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(232,243,255); TEXT-ALIGN: left"&gt;using System;&lt;br /&gt;&lt;br /&gt;namespace TypeInference&lt;br /&gt;{&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;var i = 5;&lt;br /&gt;var intArray = new int[] { 1, 2, 3, 4, 5 };&lt;br /&gt;//Variables declared with var cannot be assigned to null if no type has been inferred.&lt;br /&gt;var str = default(string);&lt;br /&gt;Console.WriteLine("Data Type Of i:"+i.GetType().Name);&lt;br /&gt;Console.WriteLine("Data Type of intArray:" + intArray.GetType().Name);&lt;br /&gt;//Console.WriteLine("Data Type of str:" + str.GetType().Name); --&gt;Null Reference Exception&lt;br /&gt;str = "";&lt;br /&gt;Console.WriteLine("Data Type of str:" + str.GetType().Name);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;} &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-3155557920761942509?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/3155557920761942509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=3155557920761942509' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/3155557920761942509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/3155557920761942509'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/05/local-type-inference-in-c-30.html' title='Local Type Inference in C# 3.0'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-7311357849808286797</id><published>2008-05-15T16:22:00.002+05:30</published><updated>2008-05-15T16:25:34.115+05:30</updated><title type='text'>Obtaining System Information in C#</title><content type='html'>&lt;p&gt;&lt;em&gt;System.Windows.Forms&lt;/em&gt; namespace has &lt;em&gt;SystemInformation&lt;/em&gt; class. The class has various static properties. To get information about the current system environment, use the class. &lt;/p&gt;&lt;p&gt;To determine the startup mode of the system, use &lt;em&gt;BootMode&lt;/em&gt; property. The property can have values : Normal, FailSafe or FailSafeWithNetwork. All these values are defined in &lt;em&gt;BootMode&lt;/em&gt; enumeration of &lt;em&gt;System.Windows.Forms&lt;/em&gt; namespace.&lt;/p&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;&lt;br /&gt;//Add reference to System.Windows.Forms assembly.&lt;br /&gt;&lt;br /&gt;namespace ConsoleApplication1&lt;br /&gt;{&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;Console.WriteLine(SystemInformation.BootMode.ToString());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;p&gt;To access the computer name, use &lt;em&gt;ComputerName&lt;/em&gt; property.&lt;/p&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;Console.WriteLine(SystemInformation.ComputeName);&lt;/div&gt;&lt;p&gt;To find out number of displays connected to machine, &lt;em&gt;MonitorCount&lt;/em&gt; propery will help us.&lt;/p&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;Console.WriteLine(SystemInformation.MonitorCount.ToString());&lt;/div&gt;&lt;p&gt;Availability of mouse can be checked with the help of property &lt;em&gt;MousePresent&lt;/em&gt;.&lt;/p&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;if(SystemInformation.MousePresent)&lt;br /&gt;Console.WriteLine("System has the mouse connected");&lt;br /&gt;}&lt;/div&gt;&lt;p&gt;To check for network connection availability, use &lt;em&gt;Network&lt;/em&gt; property.&lt;/p&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;if(SystemInformation.Network)&lt;br /&gt;Console.WriteLine("System is connected to the network.");&lt;/div&gt;&lt;p&gt;There are lot many properties exposed by &lt;em&gt;SystemInformation&lt;/em&gt; class. Check out MSDN!!!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-7311357849808286797?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/7311357849808286797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=7311357849808286797' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/7311357849808286797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/7311357849808286797'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/05/obtaining-system-information-in-c.html' title='Obtaining System Information in C#'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-8254976758886198425</id><published>2008-05-15T14:28:00.007+05:30</published><updated>2008-12-10T16:14:13.428+05:30</updated><title type='text'>Boxing and UnBoxing in C#</title><content type='html'>Boxing and unboxing are essential concepts of .NET type system.&lt;br /&gt;&lt;br /&gt;Boxing refers to conversion of value type to reference type.&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;&lt;br /&gt;int i=5;&lt;br /&gt;object o=i; //boxing&lt;/div&gt;&lt;br /&gt;Unboxing refers to the conversion of reference type to value -type.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;int j=(int)o; //Unboxing &amp;amp; type-casting.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Too much boxing and unboxing hits the application performance. Care must be taken while coding. Try to avoid boxing and unboxing.&lt;br /&gt;&lt;br /&gt;See the below code. Does the following code has boxing?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;using System;&lt;br /&gt;&lt;br /&gt;namespace BoxingDemo&lt;br /&gt;{&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;int count = 5;&lt;br /&gt;Console.WriteLine("Count:" + count);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;Look at the IL Code generated. It has &lt;strong&gt;box&lt;/strong&gt; instruction. Boxing happens here.&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_jzaues7bWBQ/SCwFgtmwGaI/AAAAAAAAABE/xs2NuCX_UL0/s1600-h/boxing.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5200537729262164386" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_jzaues7bWBQ/SCwFgtmwGaI/AAAAAAAAABE/xs2NuCX_UL0/s320/boxing.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;How to avoid it? See the code below &amp;amp; IL generated for it. It has no boxing.&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;using System;&lt;br /&gt;&lt;br /&gt;namespace BoxingDemo&lt;br /&gt;{&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;int count = 5;&lt;br /&gt;Console.WriteLine("Count:" + count.ToString());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;} &lt;/div&gt;&lt;a href="http://2.bp.blogspot.com/_jzaues7bWBQ/SCwCY9mwGZI/AAAAAAAAAA8/PqyibWQf4qA/s1600-h/noboxing.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5200534297583294866" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_jzaues7bWBQ/SCwCY9mwGZI/AAAAAAAAAA8/PqyibWQf4qA/s320/noboxing.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;Be careful!!!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-8254976758886198425?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/8254976758886198425/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=8254976758886198425' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/8254976758886198425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/8254976758886198425'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/05/boxing-and-unboxing-in-c.html' title='Boxing and UnBoxing in C#'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_jzaues7bWBQ/SCwFgtmwGaI/AAAAAAAAABE/xs2NuCX_UL0/s72-c/boxing.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-8803336674200495014</id><published>2008-05-15T14:15:00.005+05:30</published><updated>2008-12-10T16:14:13.606+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Reference Type'/><category scheme='http://www.blogger.com/atom/ns#' term='Value Type'/><title type='text'>Value Type &amp; Reference Type in .NET</title><content type='html'>&lt;a href="http://2.bp.blogspot.com/_jzaues7bWBQ/SCv6oNmwGXI/AAAAAAAAAAs/_-6o5N_5eBI/s1600-h/valuerefertypeblog.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5200525763483277682" style="margin: 0px 0px 10px 10px; float: right;" alt="" src="http://2.bp.blogspot.com/_jzaues7bWBQ/SCv6oNmwGXI/AAAAAAAAAAs/_-6o5N_5eBI/s320/valuerefertypeblog.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;Object, variables; declared in .NET Compatible languages; requires data type to be specified. Data types specifies what kind of data (textual or numeric or complex) can be stored in the object/variable.&lt;br /&gt;&lt;br /&gt;Data types in .NET are categorized in two types: Value Type and Reference Type.&lt;br /&gt;&lt;br /&gt;Value type variables are allocated on stack &amp;amp; directly store the data value. Value-types cannot be assigned to null value. Value type variable vanish when they go out-of-scope (visibility).&lt;br /&gt;&lt;br /&gt;Value types are : all primitive system types(int, float etc.) and structures, enumerations.&lt;br /&gt;&lt;br /&gt;Reference types are allocated on heap. Value gets stored in heap. The address of memory location, having value, gets stored in stack in memory location tagged with the object/variable. Heap is garbage collected. Reference type variables/objects can be assigned &lt;em&gt;null&lt;/em&gt; value.&lt;br /&gt;&lt;br /&gt;Reference types: Classes, Delegates, Arrays and Interfaces&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-8803336674200495014?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/8803336674200495014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=8803336674200495014' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/8803336674200495014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/8803336674200495014'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/05/value-type-reference-type-in-net.html' title='Value Type &amp; Reference Type in .NET'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_jzaues7bWBQ/SCv6oNmwGXI/AAAAAAAAAAs/_-6o5N_5eBI/s72-c/valuerefertypeblog.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6185477160653879498.post-3668155810175310548</id><published>2008-05-14T17:30:00.010+05:30</published><updated>2008-05-16T14:23:53.692+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='FieldOffset'/><category scheme='http://www.blogger.com/atom/ns#' term='StructLayout'/><title type='text'>Union in C#</title><content type='html'>One can simulate union in C# with the help of &lt;em&gt;StructLayout&lt;/em&gt; and &lt;em&gt;FieldOffset &lt;/em&gt;attributes.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;StructLayout&lt;/em&gt; attribute allows the user to control the physical layout of the data fields of a class or structure. Specify the &lt;em&gt;LayoutKind&lt;/em&gt; the first parameter as &lt;em&gt;LayoutKind.Explicit&lt;/em&gt;.&lt;br /&gt;&lt;br /&gt;Tag each field with &lt;em&gt;FieldOffset&lt;/em&gt; attribute. The attribute must be applied so that the type members are overlaying the same memory area.&lt;br /&gt;&lt;div style="BORDER-RIGHT: #003399 thin solid; PADDING-RIGHT: 5px; BORDER-TOP: #003399 thin solid; DISPLAY: block; PADDING-LEFT: 5px; FONT-WEIGHT: bolder; FONT-SIZE: 10px; PADDING-BOTTOM: 5px; VERTICAL-ALIGN: top; BORDER-LEFT: #003399 thin solid; COLOR: #000080; PADDING-TOP: 5px; BORDER-BOTTOM: #003399 thin solid; FONT-FAMILY: Verdana; WHITE-SPACE: pre; LETTER-SPACING: normal; BACKGROUND-COLOR: #e8f3ff; TEXT-ALIGN: left"&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Runtime.InteropServices;&lt;br /&gt;// Above namespace required for StructLayout attribute&lt;br /&gt;namespace UnionTest&lt;br /&gt;{&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;Union test = new Union();&lt;br /&gt;test.x = 256;&lt;br /&gt;//Setting value 256 makes high-order byte to be set to 1. Byte ranges up to 255.&lt;br /&gt;Console.WriteLine("Low:" + test.lowx + "\nHigh:" + test.highx);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;[StructLayout(LayoutKind.Explicit,Size=2)]&lt;br /&gt;public struct Union&lt;br /&gt;{&lt;br /&gt;//2 bytes&lt;br /&gt;[FieldOffset(0)]public short x;&lt;br /&gt;//1 byte&lt;br /&gt;[FieldOffset(0)]public byte lowx;&lt;br /&gt;//1 byte --&gt;represents high-order byte.&lt;br /&gt;[FieldOffset(1)]public byte highx;&lt;br /&gt;}&lt;br /&gt;}&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6185477160653879498-3668155810175310548?l=paddyt.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paddyt.blogspot.com/feeds/3668155810175310548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6185477160653879498&amp;postID=3668155810175310548' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/3668155810175310548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6185477160653879498/posts/default/3668155810175310548'/><link rel='alternate' type='text/html' href='http://paddyt.blogspot.com/2008/05/union-in-c.html' title='Union in C#'/><author><name>paddy (प्रदिप ताकटे)</name><uri>http://www.blogger.com/profile/09728384768392706081</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp0.blogger.com/_jzaues7bWBQ/SD7Z03O5TRI/AAAAAAAAAD4/tgfo1dInq2c/S220/blog1.JPG'/></author><thr:total>3</thr:total></entry></feed>
