<?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'><id>tag:blogger.com,1999:blog-5435296901528620140</id><updated>2009-11-08T21:40:09.772-08:00</updated><title type='text'>Microsoft Visual C#, C#.Net Interview Questions and Answers</title><subtitle type='html'>C#.Net C#, ADO, ASP, Frequently asked questions</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default?start-index=26&amp;max-results=25'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>76</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-794023808186493106</id><published>2009-07-15T08:37:00.000-07:00</published><updated>2009-07-15T08:37:00.142-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What are the new features in C# 2.0?</title><content type='html'>Support for all of the new framework features such as generics, anonymous methods, partial classes, iterators and static classes. See the .NET FAQ for more on these features.&lt;br /&gt;Delegate inference is a new feature of the C# compiler which makes delegate usage a little simpler. It allows you to write this:&lt;br /&gt;   Thread t = new Thread(ThreadFunc);&lt;br /&gt;instead of this:&lt;br /&gt;   Thread t = new Thread( new ThreadStart(ThreadFunc) );&lt;br /&gt;Another minor but welcome addition is the explicit global namespace, which fixes a hole in namespace usage in C# 1.x. You can prefix a type name with global:: to indicate that the type belongs to the global namespace, thus avoiding problems where the compiler infers the namespace and gets it wrong.&lt;br /&gt;Finally C# 2.0 includes some syntactic sugar for the new System.Nullable type. You can use T? as a synonym for System.Nullable&lt;t&gt;, where T is a value type. As suggested by the name, this allows values of the type to be 'null', or 'undefined'.&lt;/t&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-794023808186493106?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/794023808186493106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=794023808186493106' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/794023808186493106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/794023808186493106'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-are-new-features-in-c-20.html' title='What are the new features in C# 2.0?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2510517444871263563</id><published>2009-07-14T08:36:00.000-07:00</published><updated>2009-07-14T08:36:00.174-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Are C# generics the same as C++ templates?</title><content type='html'>No, not really. There are some similarities, but there are also fundamental differences. See the .NET FAQ for more details&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2510517444871263563?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2510517444871263563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2510517444871263563' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2510517444871263563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2510517444871263563'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/are-c-generics-same-as-c-templates.html' title='Are C# generics the same as C++ templates?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-4059309684244295976</id><published>2009-07-13T08:22:00.000-07:00</published><updated>2009-07-13T08:22:00.568-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Does C# support multiple inheritance?</title><content type='html'>No, use interfaces instead.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-4059309684244295976?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/4059309684244295976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=4059309684244295976' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/4059309684244295976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/4059309684244295976'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/does-c-support-multiple-inheritance.html' title='Does C# support multiple inheritance?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-1072472434956661649</id><published>2009-07-12T08:22:00.000-07:00</published><updated>2009-07-12T08:22:00.931-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How do you inherit from a class in C#?</title><content type='html'>Place a colon and then the name of the base class. Notice that it's double colon in C++.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-1072472434956661649?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/1072472434956661649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=1072472434956661649' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/1072472434956661649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/1072472434956661649'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-do-you-inherit-from-class-in-c.html' title='How do you inherit from a class in C#?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3239191086184174195</id><published>2009-07-11T08:22:00.000-07:00</published><updated>2009-07-11T08:22:00.169-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What's the implicit name of the parameter that gets passed into the class' set method?</title><content type='html'>Value, and it's datatype depends on whatever variable we're changing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-3239191086184174195?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/3239191086184174195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=3239191086184174195' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3239191086184174195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3239191086184174195'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/whats-implicit-name-of-parameter-that.html' title='What&apos;s the implicit name of the parameter that gets passed into the class&apos; set method?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2370617130423846429</id><published>2009-07-10T08:21:00.000-07:00</published><updated>2009-07-10T08:21:00.821-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Can you change the value of a variable while debugging a C# application?</title><content type='html'>Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2370617130423846429?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2370617130423846429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2370617130423846429' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2370617130423846429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2370617130423846429'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/can-you-change-value-of-variable-while.html' title='Can you change the value of a variable while debugging a C# application?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5118748043435090458</id><published>2009-07-09T08:20:00.000-07:00</published><updated>2009-07-09T08:20:00.777-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How do you generate documentation from the C# file commented properly with a command-line compiler?</title><content type='html'>Compile it with a /doc switch.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5118748043435090458?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5118748043435090458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5118748043435090458' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5118748043435090458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5118748043435090458'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-do-you-generate-documentation-from.html' title='How do you generate documentation from the C# file commented properly with a command-line compiler?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-650823525842702494</id><published>2009-07-08T08:18:00.000-07:00</published><updated>2009-07-08T08:18:01.881-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What does it meant to say “the canonical” form of XML?</title><content type='html'>"The purpose of Canonical XML is to define a standard format for an XML document. Canonical XML is a very strict XML syntax, which lets documents in canonical XML be compared directly.&lt;br /&gt;Using this strict syntax makes it easier to see whether two XML documents are the same. For example, a section of text in one document might read Black &amp;amp; White, whereas the same section of text might read Black &amp;amp; White in another document, and even in another. If you compare those three documents byte by byte, they'll be different. But if you write them all in canonical XML, which specifies every aspect of the syntax you can use, these three documents would all have the same version of this text (which would be Black &amp;amp; White) and could be compared without problem.&lt;br /&gt;This Comparison is especially critical when xml documents are digitally signed. The digital signal may be interpreted in different way and the document may be rejected.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-650823525842702494?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/650823525842702494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=650823525842702494' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/650823525842702494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/650823525842702494'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-does-it-meant-to-say-canonical.html' title='What does it meant to say “the canonical” form of XML?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5535075732367508865</id><published>2009-07-06T08:18:00.000-07:00</published><updated>2009-07-06T08:18:03.808-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What is the difference between an XML "Fragment" and an XML "Document."</title><content type='html'>An XML fragment is an XML document with no single top-level root element. To put it simple it is a part (fragment) of a well-formed xml document. (node) Where as a well-formed xml document must have only one root element.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5535075732367508865?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5535075732367508865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5535075732367508865' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5535075732367508865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5535075732367508865'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-is-difference-between-xml-fragment.html' title='What is the difference between an XML &quot;Fragment&quot; and an XML &quot;Document.&quot;'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2338988694941960757</id><published>2009-07-05T08:17:00.000-07:00</published><updated>2009-07-05T08:17:00.826-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How is a property designated as read-only?</title><content type='html'>Private DataType mPropertyName;&lt;br /&gt;public returntype PropertyName&lt;br /&gt;{&lt;br /&gt;     get{&lt;br /&gt;                       //property implementation goes here&lt;br /&gt;                       return mPropertyName;&lt;br /&gt;           }&lt;br /&gt;           // Do not write the set implementation&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2338988694941960757?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2338988694941960757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2338988694941960757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2338988694941960757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2338988694941960757'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-is-property-designated-as-read-only.html' title='How is a property designated as read-only?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3601071251973522496</id><published>2009-07-04T08:16:00.000-07:00</published><updated>2009-07-04T08:16:00.166-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How would you implement inheritance using VB.NET/C#?</title><content type='html'>When we set out to implement a class using inheritance, we must first start with an existing class from which we will derive our new subclass. This existing class, or base class, may be part of the .NET system class library framework, it may be part of some other application or .NET assembly, or we may create it as part of our existing application. Once we have a base class, we can then implement one or more subclasses based on that base class. Each of our subclasses will automatically have all of the methods, properties, and events of that base class ? including the implementation behind each method, property, and event. Our subclass can add new methods, properties, and events of its own - extending the original interface with new functionality. Additionally, a subclass can replace the methods and properties of the base class with its own new&lt;br /&gt;implementation - effectively overriding the original behavior and replacing it with new behaviors. Essentially inheritance is a way of merging functionality from an existing class into our new subclass. Inheritance also defines rules for how these methods, properties, and events can be merged. In VB.NET we can use implements keyword for inheritance, while in C# we can use the sign ( : ) between subclass and baseclass.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-3601071251973522496?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/3601071251973522496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=3601071251973522496' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3601071251973522496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3601071251973522496'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-would-you-implement-inheritance.html' title='How would you implement inheritance using VB.NET/C#?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-7102870949538426695</id><published>2009-07-03T08:15:00.000-07:00</published><updated>2009-07-03T08:15:00.744-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How does VB.NET/C# achieve polymorphism?</title><content type='html'>Polymorphism is also achieved through interfaces. Like abstract classes, interfaces also describe the methods that a class needs to implement. The difference between abstract classes and interfaces is that abstract classes always act as a base class of the related classes in the class hierarchy. For example, consider a hierarchy-car and truck classes derived from four-wheeler class; the classes two-wheeler and four-wheeler derived from an abstract class vehicle. So, the class 'vehicle' is the base class in the class hierarchy. On the other hand dissimilar classes can implement one interface. For example, there is an interface that compares two objects. This interface can be implemented by the classes like box, person and string, which are unrelated to each other.&lt;br /&gt;C# allows multiple interface inheritance. It means that a class can implement more than one interface. The methods declared in an interface are implicitly abstract. If a class implements an interface, it becomes mandatory for the class to override all the methods declared in the interface, otherwise the derived class would become abstract.&lt;br /&gt;Can you explain what inheritance is and an example of when you might use it?&lt;br /&gt;The savingaccount class has two data members-accno that stores account number, and trans that keeps track of the number of transactions. We can create an object of savingaccount class as shown below.&lt;br /&gt;       savingaccount s = new savingaccount ( "Amar", 5600.00f ) ;&lt;br /&gt;From the constructor of savingaccount class we have called the two-argument constructor of the account class using the base keyword and passed the name and balance to this constructor using which the data member's name and balance are initialised.&lt;br /&gt;We can write our own definition of a method that already exists in a base class. This is called method overriding. We have overridden the deposit( ) and withdraw( ) methods in the savingaccount class so that we can make sure that each account maintains a minimum balance of Rs. 500 and the total number of transactions do not exceed 10. From these methods we have called the base class's methods to update the balance using the base keyword. We have also overridden the display( ) method to display additional information, i.e. account number.&lt;br /&gt;Working of currentaccount class is more or less similar to that of savingaccount class.&lt;br /&gt;Using the derived class's object, if we call a method that is not overridden in the derived class, the base class method gets executed. Using derived class's object we can call base class's methods, but the reverse is not allowed.&lt;br /&gt;Unlike C++, C# does not support multiple inheritance. So, in C# every class has exactly one base class.&lt;br /&gt;Now, suppose we declare reference to the base class and store in it the address of instance of derived class as shown below.&lt;br /&gt;       account a1 = new    savingaccount ( "Amar", 5600.00f ) ;&lt;br /&gt;  account a2 = new currentaccount ( "MyCompany Pvt. Ltd.", 126000.00f) ;&lt;br /&gt;Such a situation arises when we have to decide at run-time a method of which class in a class hierarchy should get called. Using a1 and a2, suppose we call the method display( ), ideally the method of derived class should get called. But it is the method of base class that gets called. This is because the compiler considers the type of reference (account in this case) and resolves the method call. So, to call the proper method we must make a small change in our program. We must use the virtual keyword while defining the methods in base class as shown below.&lt;br /&gt;       public virtual void display( )    {   }&lt;br /&gt;We must declare the methods as virtual if they are going to be overridden in derived class. To override a virtual method in derived classes we must use the override keyword as given below.&lt;br /&gt;       public override void display( )   {   }&lt;br /&gt;Now it is ensured that when we call the methods using upcasted reference, it is the derived class's method that would get called. Actually, when we declare a virtual method, while calling it, the compiler considers the contents of the reference rather than its type.&lt;br /&gt;If we don't want to override base class's virtual method, we can declare it with new modifier in derived class. The new modifier indicates that the method is new to this class and is not an override of a base class method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-7102870949538426695?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/7102870949538426695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=7102870949538426695' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7102870949538426695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7102870949538426695'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-does-vbnetc-achieve-polymorphism.html' title='How does VB.NET/C# achieve polymorphism?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-673219440153876247</id><published>2009-07-02T07:51:00.000-07:00</published><updated>2009-07-02T07:51:01.336-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How do I run managed code in a process?</title><content type='html'>The first step in running managed code in a process is to get the CLR loaded and initialized using a CLR host. Typically, a host consists of both managed code and unmanaged code. The managed code which executes in the default domain is usually responsible for creating the application domains in which the user code exists. All CLR hosts must contain unmanaged code because execution must begin in unmanaged code. The .NET Frameworks provides a set of unmanaged APIs that the host can use to configure the CLR, load the CLR into a process, load the hosts managed code into the default domain, and transition from the unmanaged code to the managed code.&lt;br /&gt;The second step in running managed code in a process is to create application domains in which the user code will execute. The creator of the application domain can specify criteria which control code isolation, security, and loading of assemblies.&lt;br /&gt;The third step in running managed code in a process is to execute user code in one or more application domains created in the previous step. All code that is run in the CLR must be part of an assembly. There are three options for loading assemblies. First, precompiled assemblies can be loaded from disk. Second, precompiled assemblies can be loaded from an array of bytes. Third, assemblies can be built dynamically in an application domain using the BCL Reflection Emit APIs.&lt;br /&gt;Note. For an application launched from the command-line, the shell host executes the steps described above on behalf of the user and hides the complexity from the user.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-673219440153876247?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/673219440153876247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=673219440153876247' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/673219440153876247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/673219440153876247'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-do-i-run-managed-code-in-process.html' title='How do I run managed code in a process?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2485945937692452602</id><published>2009-07-01T08:15:00.000-07:00</published><updated>2009-07-01T08:15:01.442-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Explain the differences between Server-side and Client-side code?</title><content type='html'>Server side code executes on the server.For this to occur page has to be submitted or posted back.Events fired by the controls are executed on the server.Client side code executes in the browser of the client without submitting the page.&lt;br /&gt;e.g. In ASP.NET for webcontrols like asp:button the click event of the button is executed on the server hence the event handler for the same in a part of the code-behind (server-side code). Along the server-side code events one can also attach client side events which are executed in the clients browser i.e. javascript events.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2485945937692452602?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2485945937692452602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2485945937692452602' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2485945937692452602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2485945937692452602'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/explain-differences-between-server-side.html' title='Explain the differences between Server-side and Client-side code?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3491381975731282754</id><published>2009-06-30T07:50:00.000-07:00</published><updated>2009-06-30T07:50:00.245-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What is an assembly?</title><content type='html'>An assembly is a reusable, versionable, self-describing deployment unit for types and resources it is the primary building block of a .NET application. Assemblies provide the infrastructure to allow the runtime to fully understand the contents of an application and to enforce the versioning and dependency rules defined by the application.&lt;br /&gt;An assembly consists of the following two logical elements:&lt;br /&gt;        The sets of types and resources that form some logical unit of functionality.&lt;br /&gt;        A manifest which is the metadata that describes how the types and resources relate and what they depend on to work properly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-3491381975731282754?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/3491381975731282754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=3491381975731282754' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3491381975731282754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3491381975731282754'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-is-assembly.html' title='What is an assembly?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5610843076222428320</id><published>2009-06-29T07:48:00.000-07:00</published><updated>2009-06-29T07:48:00.641-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>How do I dynamically resolve assemblies, types, and resources?</title><content type='html'>The assembly resolution is controlled by the configuration properties for the application domain such as System.AppDomainSetup.ApplicationBase. The configuration properties may not be sufficient in some hosting scenarios, especially if the host is creating assemblies in memory on the fly using Reflection Emit, since there may not be an assembly on disk to find. In such cases, you can use the System.AssemblyResolve event to hook into the type loading process.&lt;br /&gt;The AssemblyResolve event is defined as follows:&lt;br /&gt;public event ResolveEventHandler AssemblyResolve&lt;br /&gt;where System.ResolveEventHandler is defined as follows:&lt;br /&gt;public delegate Assembly ResolveEventHandler(Object sender, ResolveEventArgs args)&lt;br /&gt;The args parameter to ResolveEventHandler is the identity of the assembly the runtime is seeking. The receipient of the event is free to resolve the reference to the assembly by any means. For example, the receipient may construct an assembly on the fly, find it in a custom location on disk, etc. The only requirement is that the receipient return a instance of System.Reflection.Assembly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5610843076222428320?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5610843076222428320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5610843076222428320' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5610843076222428320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5610843076222428320'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/how-do-i-dynamically-resolve-assemblies.html' title='How do I dynamically resolve assemblies, types, and resources?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-3642500269575893763</id><published>2009-06-29T07:46:00.000-07:00</published><updated>2009-06-29T07:46:01.119-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?</title><content type='html'>Document Type Definition (DTD) describes a model or set of rules for an XML document. XML Schema Definition (XSD) also describes the structure of an XML document but XSDs are much more powerful.&lt;br /&gt;The disadvantage with the Document Type Definition is it doesn’t support data types beyond the basic 10 primitive types. It cannot properly define the type of data contained by the tag.&lt;br /&gt;An Xml Schema provides an Object Oriented approach to defining the format of an xml document. The Xml schema support most basic programming types like integer, byte, string, float etc., We can also define complex types of our own which can be used to define a xml document.&lt;br /&gt;Xml Schemas are always preferred over DTDs as a document can be more precisely defined using the XML Schemas because of its rich support for data representation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-3642500269575893763?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/3642500269575893763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=3642500269575893763' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3642500269575893763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/3642500269575893763'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/contrast-dtds-versus-xsds-what-are.html' title='Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-8383307576123629130</id><published>2009-06-28T07:45:00.000-07:00</published><updated>2009-06-28T07:45:01.071-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>Where do you add an event handler?</title><content type='html'>It's the Attributesproperty, the Add function inside that property.&lt;br /&gt;e.g. btnSubmit.Attributes.Add(""onMouseOver"",""someClientCode();"")&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-8383307576123629130?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/8383307576123629130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=8383307576123629130' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/8383307576123629130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/8383307576123629130'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/where-do-you-add-event-handler.html' title='Where do you add an event handler?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-7863093867267033220</id><published>2009-06-27T07:45:00.000-07:00</published><updated>2009-06-27T07:45:00.552-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What are jagged array ?</title><content type='html'>First lets us answer the question that what an array is?&lt;br /&gt;The dictionary meaning of array is an orderly arrangement or sequential arrangement of elements.&lt;br /&gt;In computer science term:&lt;br /&gt;An array is a data structure that contains a number of variables, which are accessed through computed indices. The variables contained in an array, also called the elements of the array, are all of the same type, and this type is called the element type of the array.&lt;br /&gt;An array has a rank that determines the number of indices associated with each array element. The rank of an array is also referred to as the dimensions of the array. An array with a rank of one is called a single-dimensional array. An array with a rank greater than one is called a multi-dimensional array. Specific sized multidimensional arrays are often referred to as two-dimensional arrays, three-dimensional arrays, and so on.&lt;br /&gt;Now let us answer What are jagged arrays?&lt;br /&gt;A jagged array is an array whose elements are arrays. The elements of jagged array can be of different dimensions and sizes. A jagged array is sometimes called as “array-of-arrays”. It is called jagged because each of its rows is of different size so the final or graphical representation is not a square.&lt;br /&gt;When you create a jagged array you declare the number of rows in your array. Each row will hold an array that will be on any length. Before filling the values in the inner arrays you must declare them.&lt;br /&gt;Jagged array declaration in C#:&lt;br /&gt;For e.g. : int [] [] myJaggedArray = new int [3][];&lt;br /&gt;Declaration of inner arrays:&lt;br /&gt;&lt;br /&gt;myJaggedArray[0] = new int[5] ;   // First inner array will be of length 5.&lt;br /&gt;myJaggedArray[1] = new int[4] ;  // Second inner array will be of length 4.&lt;br /&gt;myJaggedArray[2] = new int[3] ;   // Third inner array will be of length 3.&lt;br /&gt;Now to access third element of second row we write:&lt;br /&gt; int value = myJaggedArray[1][2];&lt;br /&gt;Note that while declaring the array the second dimension is not supplied because this you will declare later on in the code.&lt;br /&gt;Jagged array are created out of single dimensional arrays so be careful while using them. Don’t confuse it with multi-dimensional arrays because unlike them jagged arrays are not rectangular arrays.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-7863093867267033220?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/7863093867267033220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=7863093867267033220' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7863093867267033220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7863093867267033220'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-are-jagged-array.html' title='What are jagged array ?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2986914339178393640</id><published>2009-06-26T07:44:00.000-07:00</published><updated>2009-06-26T07:44:00.596-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>If you define integer variable and a object variable and a structure then how those will be plotted in memory.</title><content type='html'>Integer , structure – System.ValueType  -- Allocated memory on stack , infact integer is primitive type recognized and allocated memory by compiler itself .&lt;br /&gt;Infact , System.Int32 definition is as follows :&lt;br /&gt;[C#]&lt;br /&gt;[Serializable]&lt;br /&gt;public struct Int32 : IComparable, IFormattable, IConvertible&lt;br /&gt;So , it’s a struct by definition , which is the same case with various other value types .&lt;br /&gt;Object – Base class , that is by default reference type , so at runtime JIT compiler allocates memory on the “Heap” Data structure .&lt;br /&gt;Reference types are defined as class , derived directly or indirectly by System.ReferenceType&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2986914339178393640?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2986914339178393640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2986914339178393640' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2986914339178393640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2986914339178393640'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/if-you-define-integer-variable-and.html' title='If you define integer variable and a object variable and a structure then how those will be plotted in memory.'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-7161653562287095946</id><published>2009-06-25T07:44:00.000-07:00</published><updated>2009-06-25T07:44:02.783-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What is a delegate, why should you use it and how do you call it ?</title><content type='html'>A delegate is a reference type that refers to a Shared method of a type or to an instance method of an object. Delegate is like a function pointer in C and C++.  Pointers are used to store the address of a thing. Delegate lets some other code call your function without needing to know where your function is actually located. All events in .NET actually use delegates in the background to wire up events. Events are really just a modified form of a delegate.&lt;br /&gt;It should give you an idea of some different areas in which delegates may be appropriate:&lt;br /&gt; They enable callback functionality in multi-tier applications as demonstrated in the examples above. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt; The CacheItemRemoveCallback delegate can be used in ASP.NET to keep cached information up to date. When the cached information is removed for any reason, the associated callback is exercised and could contain a reload of the cached information. &lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt; Use delegates to facilitate asynchronous processing for methods that do not offer asynchronous behavior.&lt;br /&gt; Events use delegates so clients can give the application events to call when the event is fired. Exposing custom events within your applications requires the use of delegates.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-7161653562287095946?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/7161653562287095946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=7161653562287095946' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7161653562287095946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/7161653562287095946'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-is-delegate-why-should-you-use-it.html' title='What is a delegate, why should you use it and how do you call it ?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5077300570670082706</id><published>2009-06-24T07:09:00.000-07:00</published><updated>2009-06-24T07:09:00.618-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What's the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?</title><content type='html'>A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5077300570670082706?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5077300570670082706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5077300570670082706' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5077300570670082706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5077300570670082706'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/whats-c-equivalent-of-c-catch-which-was.html' title='What&apos;s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-5906287118714709978</id><published>2009-06-23T07:07:00.000-07:00</published><updated>2009-06-23T07:07:00.618-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What's the difference between const and readonly?</title><content type='html'>The readonly keyword is different from the const keyword. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used. Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants as in the following example:&lt;br /&gt;public static readonly uint l1 = (uint) DateTime.Now.Ticks;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-5906287118714709978?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/5906287118714709978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=5906287118714709978' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5906287118714709978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/5906287118714709978'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/whats-difference-between-const-and.html' title='What&apos;s the difference between const and readonly?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-8350604848488061275</id><published>2009-06-22T07:00:00.000-07:00</published><updated>2009-06-22T07:00:54.222-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>What is hiding in CSharp ?</title><content type='html'>Hiding is also called as Shadowing. This is the concept of Overriding the methods. It is a concept used in the Object Oriented Programming.&lt;br /&gt;&lt;br /&gt;E.g.&lt;br /&gt;public class ClassA {&lt;br /&gt;public virtual void MethodA() {&lt;br /&gt;Trace.WriteLine("ClassA Method");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class ClassB : ClassA {&lt;br /&gt;public new void MethodA() {&lt;br /&gt;Trace.WriteLine("SubClass ClassB Method");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class TopLevel {&lt;br /&gt;static void Main(string[] args) {&lt;br /&gt;TextWriter tw = Console.Out;&lt;br /&gt;Trace.Listeners.Add(new TextWriterTraceListener(tw));&lt;br /&gt;&lt;br /&gt;ClassA obj = new ClassB();&lt;br /&gt;obj.MethodA(); // Outputs “Class A Method"&lt;br /&gt;&lt;br /&gt;ClassB obj1 = new ClassB();&lt;br /&gt;obj.MethodA(); // Outputs “SubClass ClassB Method”&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-8350604848488061275?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/8350604848488061275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=8350604848488061275' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/8350604848488061275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/8350604848488061275'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/04/what-is-hiding-in-csharp.html' title='What is hiding in CSharp ?'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5435296901528620140.post-2455291705317858444</id><published>2008-10-23T03:32:00.001-07:00</published><updated>2008-12-22T21:16:10.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C#.Net'/><title type='text'>The C# Tutorial</title><content type='html'>&lt;title&gt;Lesson 10&lt;/title&gt;&lt;span style="font-family:Trebuchet MS;"&gt; &lt;h3&gt;&lt;span style="color:#ff9900;"&gt;&lt;br /&gt;&lt;!--mstheme--&gt;&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;by Joe Mayo, 02/10/01&lt;/span&gt;&lt;/p&gt; &lt;h4&gt;&lt;!--mstheme--&gt;&lt;span style="color:#6666ff;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Lesson 10:  Properties&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h4&gt; &lt;p&gt;This lesson teaches C# Properties.  Our objectives are as follows:&lt;/p&gt;&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;&lt;!--msthemelist--&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="baseline" width="42"&gt;&lt;img src="Lesson%2010_files/abpyobull1.gif" width="8" height="15" hspace="17" /&gt;&lt;/td&gt; &lt;td valign="top" width="100%"&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Understand  What Properties Are For.&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt;&lt;/td&gt;&lt;/tr&gt;&lt;!--msthemelist--&gt; &lt;tr&gt; &lt;td valign="baseline" width="42"&gt;&lt;img src="Lesson%2010_files/abpyobull1.gif" width="8" height="15" hspace="17" /&gt;&lt;/td&gt; &lt;td valign="top" width="100%"&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Implement a  Property.&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt;&lt;/td&gt;&lt;/tr&gt;&lt;!--msthemelist--&gt; &lt;tr&gt; &lt;td valign="baseline" width="42"&gt;&lt;img src="Lesson%2010_files/abpyobull1.gif" width="8" height="15" hspace="17" /&gt;&lt;/td&gt; &lt;td valign="top" width="100%"&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Create a  Read-Only Property.&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt;&lt;/td&gt;&lt;/tr&gt;&lt;!--msthemelist--&gt; &lt;tr&gt; &lt;td valign="baseline" width="42"&gt;&lt;img src="Lesson%2010_files/abpyobull1.gif" width="8" height="15" hspace="17" /&gt;&lt;/td&gt; &lt;td valign="top" width="100%"&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Create a  Write-Only Property.&lt;!--mstheme--&gt;&lt;/span&gt;&lt;!--msthemelist--&gt;&lt;/td&gt;&lt;/tr&gt;&lt;!--msthemelist--&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;!--mstheme--&gt;&lt;span style="font-family:Trebuchet MS;"&gt; &lt;p&gt;Properties are a new language feature introduced with C#.  They provide the  opportunity to protect a field in a class by reading and writing to it through  the property.  In other languages, this is accomplished by programs implementing  specialized getter and setter methods.  C# properties enable this type of  protection while also letting you access the property just like it was a field.   To get an appreciation for what properties accomplish, let's take a look at how  to provide field encapsulation by traditional methods.&lt;/p&gt; &lt;h5&gt;&lt;!--mstheme--&gt;&lt;span style="color:#ff0000;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Listing 10-1.  An Example  of Traditional Class Field Access:  Accessors.cs&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h5&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  System;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty =  0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; getSomeProperty()&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;   &lt;span style="font-size:85%;color:#0000ff;"&gt;     return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty;&lt;br /&gt;     }&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;    public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;void&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  setSomeProperty(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  propValue)&lt;br /&gt;    {&lt;br /&gt;        someProperty = propValue;&lt;br /&gt;     }&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt; PropertyTester&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Main(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:85%;"&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        PropertyHolder  propHold = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder();&lt;br /&gt;&lt;br /&gt;        propHold.setSomeProperty(5);&lt;br /&gt;&lt;br /&gt;         Console.WriteLine("Property Value: {0}",  propHold.getSomeProperty());&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0;&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt; &lt;p&gt;Listing 10-1 shows the traditional method of accessing class fields.  The  PropertyHolder class has the field we're interested in accessing.  It has two  methods, getSomeProperty and setSomeProperty.  The getSomeProperty method  returns the value of the someProperty field.  The setSomeProperty method sets  the value of the someProperty field.&lt;/p&gt; &lt;p&gt;The PropertyTester class uses the methods of the PropertyHolder class to get  the value of the someProperty field in the PropertyHolder class.  The Main  method instantiates a new PropertyHolder object, propHold.  Next it sets the  someMethod of propHold to the value 5 by using the setSomeProperty method.  Then  the program prints out the property value with a Console.WriteLine method call.   The argument used to obtain the value of the property is a call to the  getSomeProperty method of the propHold object.  It prints out "Property Value:  5" to the console.&lt;/p&gt; &lt;p&gt;This method of accessing information in a field has been good because it  supports the object-oriented concept of encapsulation.  If the implementation of  someProperty changed from an int type to a byte type, this would still work.   Now the same thing can be accomplished much smoother with properties.&lt;/p&gt; &lt;h5&gt;&lt;!--mstheme--&gt;&lt;span style="color:#ff0000;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Listing 10-2.  Accessing  Class Fields With Properties:   Properties.cs&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h5&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  System;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty =  0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; SomeProperty&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;   &lt;/span&gt;    &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;         &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty;&lt;br /&gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;   &lt;/span&gt;    &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;             someProperty = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;span style="font-size:85%;"&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt; PropertyTester&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Main(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:85%;"&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        PropertyHolder  propHold = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder();&lt;br /&gt;&lt;br /&gt;        propHold.SomeProperty = 5;&lt;br /&gt;&lt;br /&gt;         Console.WriteLine("Property Value: {0}", propHold.SomeProperty);&lt;br /&gt;&lt;br /&gt;         &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0;&lt;br /&gt;     }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt; &lt;p&gt;Listing 10-2 shows how to create and use a property.  The PropertyHolder  class has the "SomeProperty" property implementation.  Notice that the first  letter of the first word is capitalized.  That's the only difference between the  names of the property "SomeProperty" and the field "someProperty".  The property  has two accessors, get and set.  The get accessor returns the value of the  someProperty field.  The set accessor sets the value of the someProperty field  with the contents of "value".  The "value" shown in the set accessor is a C#  reserved word.  It's normally an error to use the "value" keyword in any other  context.&lt;/p&gt; &lt;p&gt;The PropertyTester class uses the SomeProperty property in the PropertyHolder  class.  The first line of the Main method creates a PropertyHolder object named  propHold.  Next the value of the someProperty field of the propHold object is  set to 5 by using the SomeProperty property.  It's that simple -- just assign  the value to the property as if it were a field.&lt;/p&gt; &lt;p&gt;After that, the Console.WriteLine method prints the value of the someProperty  field of the propHold object.  It does this by using the SomeProperty property  of the propHold object.  Again, it's that simple -- just use the property as if  it were a field itself.&lt;/p&gt; &lt;p&gt;Properties can be made read-only.  This is accomplished by having only a get  accessor in the property implementation.&lt;/p&gt; &lt;h5&gt;&lt;!--mstheme--&gt;&lt;span style="color:#ff0000;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Listing 10-3.  Read-Only  Property:  ReadOnlyProperty.cs&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h5&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  System;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty =  0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; PropertyHolder(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; propVal)&lt;br /&gt;    {&lt;br /&gt;         someProperty = propVal;&lt;br /&gt;    }&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;br /&gt;&lt;br /&gt;     public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; SomeProperty&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;   &lt;/span&gt;    &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;         &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty;&lt;br /&gt;        }&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyTester&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Main(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:85%;"&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        PropertyHolder  propHold = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder(5);&lt;br /&gt;&lt;br /&gt;        Console.WriteLine("Property Value: {0}",  propHold.SomeProperty);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  0;&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt; &lt;p&gt;Listing 10-3 shows how to implement a read-only property.  The PropertyHolder  class has a SomeProperty property that only implements a get accessor.  It  leaves out the set accessor.  This particular PropertyHolder class has a  constructor which accepts an integer parameter.&lt;/p&gt; &lt;p&gt;The Main method of the PropertyTester class creates a new PropertyHolder  object named propHold.  The instantiation of the propHold object uses the  constructor of the PropertyHolder that takes an int parameter.  In this case,  it's set to 5.  This initializes the someProperty field of the propHold object  to 5.&lt;/p&gt; &lt;p&gt;Since the SomeProperty property of the PropertyHolder class is read-only,  there is no other way to set the value of the someProperty field.  If you  inserted "propHold.SomeProperty = 7" into the listing, the program would not  compile, because SomeProperty is read-only.  When the SomeProperty property is  used in the Console.WriteLine method, it works fine.  This is because it's a  read operation which only invokes the get accessor of the SomeProperty  property.&lt;/p&gt; &lt;h5&gt;&lt;!--mstheme--&gt;&lt;span style="color:#ff0000;"&gt;&lt;!--mstheme--&gt;&lt;b&gt;Listing 10-4.  Write-Only  Property:  WriteOnlyProperty.cs&lt;!--mstheme--&gt;&lt;/b&gt;&lt;/span&gt;&lt;!--mstheme--&gt;&lt;b&gt;&lt;/b&gt;&lt;/h5&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  System;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;  &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; someProperty =  0;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; SomeProperty&lt;br /&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;   &lt;/span&gt;    &lt;span style="font-size:85%;"&gt;{&lt;br /&gt;             someProperty = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;span style="font-size:85%;"&gt;;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("someProperty is equal to {0}",  someProperty);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;"&gt; PropertyTester&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Main(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:85%;"&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        PropertyHolder  propHold = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;  PropertyHolder();&lt;br /&gt;&lt;br /&gt;        propHold.SomeProperty = 5;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;   &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0;&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Listing 10-4 shows how to create and use a write-only property.  This time  the get accessor is removed from the SomeProperty property of the PropertyHolder  class.  The set accessor has been added, with a bit more logic.  It prints out  the value of the someProperty field after it's been modified.&lt;/p&gt; &lt;p&gt;The Main method of the PropertyTester class instantiates the PropertyTester  class with a default constructor.  Then it uses the SomeProperty property of the  propHold object to set the someProperty field of the propHold object to 5.  This  invokes the set accessor of the propHold object, which sets the value of it's  someProperty field to 5 and then prints "someProperty is equal to 5" to the  console.&lt;/p&gt; &lt;p&gt;In summary, you now know what properties are for and how they're used.  You  have a feeling for the difference between using properties and traditional  techniques using class methods.  Properties can be made read-only or write-only  and you know how to implement each type.&lt;/p&gt; &lt;p&gt;I invite you to return for Lesson 11:  Indexers.&lt;/p&gt; &lt;p&gt;Your feedback is very important and I appreciate any constructive  contributions you have. Please feel free to contact me for any questions or  comments you may have about this lesson&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5435296901528620140-2455291705317858444?l=microsoftcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microsoftcsharp.blogspot.com/feeds/2455291705317858444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=5435296901528620140&amp;postID=2455291705317858444' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2455291705317858444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5435296901528620140/posts/default/2455291705317858444'/><link rel='alternate' type='text/html' href='http://microsoftcsharp.blogspot.com/2008/10/c-tutorial.html' title='The C# Tutorial'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>sumedhgad@rediffmail.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='07549647743637739572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry></feed>