<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-7133335550635087088</atom:id><lastBuildDate>Thu, 19 Dec 2024 03:29:55 +0000</lastBuildDate><category>C#</category><category>.Net Framework</category><category>C# Interface</category><category>C# Method</category><category>Introduction</category><category>OOPS</category><category>Object Oriented Programming</category><category>Access Specifier(s)</category><category>Arrays</category><category>C# Array</category><category>C# Destructor</category><category>C# Enumerator</category><category>C# Function</category><category>Conditional Operators</category><category>Constructor(s)</category><category>Data types</category><category>Fibonacci</category><category>Function Overloading</category><category>Loops</category><category>Object</category><category>Operators in C#</category><category>String Handling</category><category>Variables</category><title>C# and ASP.net tutorials for beginners....</title><description></description><link>http://csharpasp.blogspot.com/</link><managingEditor>noreply@blogger.com (Smilu Varghese)</managingEditor><generator>Blogger</generator><openSearch:totalResults>22</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-3584382262986727645</guid><pubDate>Wed, 08 Jul 2009 05:27:00 +0000</pubDate><atom:updated>2009-07-08T11:07:04.179+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# Enumerator</category><title>C# Enum - Enumerator</title><description>&lt;div&gt;An &lt;b&gt;enumerator&lt;/b&gt; is a Distinct Type containg a set of Named Constants called Enumerator List. We create an Enumerator with the enum keyword. Enumerator can be of any integer type.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let&#39;s see an example for that&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;  &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;enum &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Gender &lt;/span&gt;{ Male, Female };&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;or&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;enum &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Gender &lt;/span&gt;:&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int&lt;/span&gt; &lt;/span&gt;{ Male, Female };&lt;/span&gt;&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The above one is and Enumerator with the name &lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;b&gt;Gender&lt;/b&gt;&lt;/span&gt;. Now we can get the values &lt;i&gt;Male &lt;/i&gt;or &lt;i&gt;Female&lt;/i&gt; using the enumerator Gender. By default the Value of the First element of the enumerator will be 0 and the rest will be increased by 1.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you need to use the Enumerator then you can access it using the Gender keyword.&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Gender&lt;/span&gt;.Male);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;or&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Gender&lt;/span&gt;.Female);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and if you need to take the value of this Enumerator you can do it like this..&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int &lt;/span&gt;i=(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int&lt;/span&gt;)&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Gender&lt;/span&gt;.Male;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here in the above code the value will be 0 for the variable i, and if you can take Female the value will be 1.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can change the values of the enumerator elements in manual.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;  &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;enum &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Gender &lt;/span&gt;{ Male=1, Female }; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here we forcefully change the value of the first element of the enumerator, so all the rest will be having values after that.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now let&#39;s See and Example for C# Enumerator..&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;using &lt;/span&gt;System;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;namespace &lt;/span&gt;ConsoleApplication1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Program&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;       &lt;i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#009900;&quot;&gt; //Creating an Enumerator&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;enum &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;WeekDays &lt;/span&gt;{ Sunday=1, Monday,Tuesday, Wednesday,Thursday, Friday, Saturday};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;static void&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Main&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;&quot;The value for the  week day {0} is {1}&quot;&lt;/span&gt;,&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;WeekDays&lt;/span&gt;.Thursday, (&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int&lt;/span&gt;)&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;WeekDays&lt;/span&gt;.Thursday);            &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;--------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The output of the Program will be:-&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#009900;&quot;&gt;The value for the  week day Thursday is 5.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://csharpasp.blogspot.com/2009/07/c-enum-enumerator.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-6568071848574440795</guid><pubDate>Mon, 06 Jul 2009 05:54:00 +0000</pubDate><atom:updated>2009-07-08T11:31:01.865+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# Interface</category><title>C# Interface</title><description>&lt;div&gt;An &lt;a href=&quot;http://csharpasp.blogspot.com/2009/07/what-is-interface-in-c.html&quot;&gt;interface&lt;/a&gt; is Created using the &lt;i&gt;interface &lt;/i&gt;Keyword. &lt;/div&gt;&lt;div&gt;Here is an example for the Interface program.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;----------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;interface &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;IStudent&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int &lt;/span&gt;RollNo&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;get&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;set&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string &lt;/span&gt;Name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;get&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;set&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt; &lt;/span&gt;DispDetails();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;-----------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The above one is an interface named &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;&lt;i&gt;&lt;b&gt;IStudent&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;. In this there are two Properties namely &lt;i&gt;RollNo&lt;/i&gt; and &lt;i&gt;Name&lt;/i&gt;. There is also a Method named &lt;i&gt;DispDetails&lt;/i&gt;(). If you look at the codes... we don&#39;t have any definitions for these properties and Method(s). &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, we will check how we can implement these codes inside a Class. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Exaple for C# Interface:-&lt;/div&gt;&lt;div&gt;-----------------------------------------&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;//Inheriting interface IStudent to class MySchool&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;MySchool &lt;/span&gt;: &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;IStudent&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int &lt;/span&gt;iRollNo = 0;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string &lt;/span&gt;sName = &quot;&quot;;]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#009900;&quot;&gt;//Definition for Property Declared inside the Interface&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;public &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int &lt;/span&gt;RollNo&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;get &lt;/span&gt;{ &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;return &lt;/span&gt;iRollNo; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;set &lt;/span&gt;{ iRollNo = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;value&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;public &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string &lt;/span&gt;Name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;get &lt;/span&gt;{ &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;return &lt;/span&gt;sName; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;set &lt;/span&gt;{ sName = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;value&lt;/span&gt;; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#009900;&quot;&gt;//Definition for Method Declared inside the Interface.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;public &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;void &lt;/span&gt;DispDetails()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;&quot;The RollNo is:{0} and the Name is {1}&quot;&lt;/span&gt;, iRollNo, sName);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;static &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;void &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Main&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;MySchool &lt;/span&gt;sObj = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;MySchool&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            sObj.RollNo = 12500;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            sObj.Name = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;&quot;SMILU&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            sObj.DispDetails();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;--------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the above class &lt;i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;MySchool &lt;/span&gt;&lt;/i&gt;we have Inherited the &lt;i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;IStudent &lt;/span&gt;&lt;/i&gt;interface. So it&#39;s mandatory that we must write the Definitions for those methods and Properties declared inside the Interface. &lt;/div&gt;&lt;div&gt;Now, If in case we don&#39;t give a definition for any method or property declared inside the Interface, it will throw Error(s) and we will not be able to execute the program.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, its necessary that there must be definition for all the methods and Properties which we have inside our Interface.&lt;/div&gt;</description><link>http://csharpasp.blogspot.com/2009/07/c-interface.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-3915337146893277999</guid><pubDate>Mon, 06 Jul 2009 05:22:00 +0000</pubDate><atom:updated>2009-07-06T11:36:46.943+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# Interface</category><title>What is an Interface in C#?</title><description>&lt;div&gt;An Interface is an abstract type which we use to Implement certain Rules to our class. &lt;/div&gt;&lt;div&gt;This will be certain contracts that we need to Implement into our C# class. Interface will not be having any definitions for the methods and properties it has. We just create the Prototype of methods and Properties we need to implement inside the class. Which all classes Inherit these Interfaces Must have the definitions for the Methods and Properties which we have Declared inside the Interface. We create an Interface using the &lt;i&gt;&lt;b&gt;interface &lt;/b&gt;&lt;/i&gt;keyword.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;See an C# Interface  &lt;b&gt;&lt;a href=&quot;http://csharpasp.blogspot.com/2009/07/c-interface.html&quot;&gt;EXAMPLE&lt;/a&gt; &lt;/b&gt;here....&lt;/div&gt;</description><link>http://csharpasp.blogspot.com/2009/07/what-is-interface-in-c.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-6537003741679776747</guid><pubDate>Mon, 29 Jun 2009 11:32:00 +0000</pubDate><atom:updated>2009-06-29T17:26:07.912+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">String Handling</category><title>C# string handling - Part 1</title><description>&lt;div&gt;We have lots of string handling functions in C#.net. We are just going to see some basic &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;functions.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF6600;&quot;&gt;C# string Split()&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; - Splitting a string to an Array&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The &lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;split()&lt;/span&gt; can be used to Split an entire string in to an string array. This will be &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;done using this split method. This can be used when you need long strings to be splitted &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;to seperate string objects.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;---------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string &lt;/span&gt;mString = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;&quot;This is to show Splitting in strings&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string&lt;/span&gt;[] mArr = mString.Split(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;&#39; &#39;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;---------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here in the above code we have a string named mString and we have assigned a string to &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;it. Now check the second line of it. We have created an String Array to store the values &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;that gets Splitted. &lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;mString.Split(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;&#39; &#39;&lt;/span&gt;) &lt;/span&gt;method splits the Entire string into an array. We have given a white &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;space as the argument for the &lt;i&gt;&lt;b&gt;Split &lt;/b&gt;&lt;/i&gt;method for the string. This will allow it to split &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;the string whenever it sees a white space inside the string.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, if you need to get the Splitted values of the string you must have to fetch the &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;entire items of the Array &lt;i&gt;&lt;b&gt;mArr &lt;/b&gt;&lt;/i&gt;using some loops.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF6600;&quot;&gt;&lt;b&gt;C# string.Join()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;- Joining an Array as a String&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The &lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;Join()&lt;/span&gt; method can be used to join an Array to a single String. If we have an array &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;to be used as a single string you can use this string.Join() method. &lt;/div&gt;&lt;div&gt;Let&#39;s see an example for it&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;---------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string &lt;/span&gt;joinedString = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string&lt;/span&gt;.Join(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;&quot;-&quot;&lt;/span&gt;, mArr);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;//Here the JoinedString variables value will be &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;// &quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;This&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;is&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;Splitting&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;strings&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;---------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the above code in the Join function we have two overloads  mainly&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string.Join(&quot;String Separator&quot;,&quot;The array to Join&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Here in the above we have set the Separator as &quot;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;-&lt;/span&gt;&quot;(&lt;i&gt;hyphen&lt;/i&gt;). So it will attach each Array &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;element with this &quot;-&quot;. Like wise we can join the Strings in any way we like.&lt;/div&gt;</description><link>http://csharpasp.blogspot.com/2009/06/c-string-handling-part-1.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-7133407159961573087</guid><pubDate>Wed, 17 Jun 2009 05:03:00 +0000</pubDate><atom:updated>2009-06-18T10:07:58.934+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Fibonacci</category><title>Write a Program to show numbers in Fibonacci Series in C#??</title><description>&lt;div&gt;Fibonacci series is a pattern in which digits are shown in a manner that it adds the last two digit from the series ie..&lt;/div&gt;&lt;div&gt;0 1 1 2 3 5 8......... n..&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here, the first no is 0 and the second no is 1 so the third number must be 0+1, and the fourth number must be Sum of Second and Third.. ie 1+1, like wise we must create it for the Entire Series....&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Here is the Program to show the first ten digits in Fibonacci Series in C#...&lt;div&gt;----------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;using &lt;/span&gt;System;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;namespace &lt;/span&gt;MyFibonacciApp&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;_FibonacciSeries&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;       &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt; static void&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Main&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int &lt;/span&gt;j = 0;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int &lt;/span&gt;k = 0;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int &lt;/span&gt;l = 1;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;int &lt;/span&gt;i = 0; i &lt;10;i++)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;                &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Console&lt;/span&gt;.Write(&quot;{0} &quot;, k);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;                j = l; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;                l = k;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;                k = l + j;               &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;----------------------------------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://csharpasp.blogspot.com/2009/06/write-program-to-show-numbers-in.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-5194554422764249602</guid><pubDate>Sat, 13 Jun 2009 05:26:00 +0000</pubDate><atom:updated>2009-06-13T11:23:49.937+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# Destructor</category><title>Destructor in C#</title><description>C# Destructors are used to destroy an object of a Class. Destructors are automatically invoked when the Scope of the Object goes out. We represent a Destructor with a tilde(~) symbol. Destructor will also be having the Same name of the class. &lt;div&gt;If there is a class with the name &quot;Hello&quot; we can represent its destructor as&lt;/div&gt;&lt;div&gt;~Hello()&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Destructors cannot be overloaded, Inhertied or have Modifiers defined to it.&lt;/div&gt;&lt;div&gt;we can see a Simple program..&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-------------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;using &lt;/span&gt;System;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;namespace &lt;/span&gt;Destructorss&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;One&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#999900;&quot;&gt;//Constructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;public &lt;/span&gt;One()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;Console&lt;/span&gt;.WriteLine(&quot;First Constructor Called&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#009900;&quot;&gt;//Destructor&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        ~One()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;Console&lt;/span&gt;.WriteLine(&quot;First destructor is called.&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;           &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Two &lt;/span&gt;: &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;One&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(153, 153, 0); &quot;&gt;//Constructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;public &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Two&lt;/span&gt;()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;Console&lt;/span&gt;.WriteLine(&quot;Second Constructor Called&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 153, 0); &quot;&gt;//Destructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        ~Two()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;Console&lt;/span&gt;.WriteLine(&quot;Second destructor is called.&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Three &lt;/span&gt;: &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Two&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(153, 153, 0); &quot;&gt;//Constructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;public &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Three&lt;/span&gt;()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Console&lt;/span&gt;.WriteLine(&quot;Third Constructor Called&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 153, 0); &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;//Destructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        ~Three()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Console&lt;/span&gt;.WriteLine(&quot;Third destructor is called.&quot;);         &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;MyDestructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;static &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;void &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Main&lt;/span&gt;()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Three&lt;/span&gt; t = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;Three&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;/*The result of this Program will be:-&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;First Constructor Called&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;Second Constructor Called&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;Third Constructor Called&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;Third destructor is called.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;Second destructor is called.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;First destructor is called.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-------------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the above program we have constructors and Destructors. Constuctors invoke from the First to the Third while Destructors go just in the Opposite way ie it starts from Third destrucor and goes to First....&lt;/div&gt;&lt;/div&gt;</description><link>http://csharpasp.blogspot.com/2009/06/destructor-in-c.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-2885199049693994257</guid><pubDate>Mon, 24 Nov 2008 06:20:00 +0000</pubDate><atom:updated>2008-11-24T11:53:50.618+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Constructor(s)</category><title>C# Constructor(s)</title><description>what are Constructors?&lt;br /&gt;&lt;br /&gt;Constructors are methods that gets automatically invoked when an object of a class is created. Constructors are used to Initialize values to variables inside the class automatically at the time of object creation.&lt;br /&gt;Constructors will be having the same name of the class itself. Constructor doesn&#39;t return any value.&lt;br /&gt;&lt;br /&gt;Let&#39;s see an example for Constructor..&lt;br /&gt;&lt;br /&gt;-------------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;using System;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;class HelloWorld&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;int iNum1,iNum2;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;string sName,sAddress;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    //Creating a Constructor&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    public HeloWorld()        //Line1&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        iNum1=iNum2=0;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        sName=&quot;&quot;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        sAddress=&quot;&quot;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;-------------------------------------&lt;br /&gt;&lt;br /&gt;Here, in the above code we have created a default constructor with the name of the class. Constructors will not be having a return type.&lt;br /&gt;&lt;br /&gt;The Line1 represents the constructor for the class HelloWorld. The same name of the class itself will be given to constructor also.&lt;br /&gt;&lt;br /&gt;We can have multiple constructors inside a class but should be overloaded. We use overloaded constructors for initializing values by passing it to the object of the class.&lt;br /&gt;&lt;br /&gt;Eg&lt;br /&gt;-------------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;using System;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;class HelloWorld&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;int iNum1,iNum2;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;string sName,sAddress;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    //Creating a Constructor&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    public HeloWorld()        //Line1&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        iNum1=iNum2=0;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        sName=&quot;&quot;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        sAddress=&quot;&quot;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    //Overloaded constructor&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    public HelloWorld(int _iNum,string _sName,string _sAddress)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        iNum1=_iNum;     //Line1&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        sName=_sName;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        sAddress=_sAddress;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        iNum2=0;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;-------------------------------------&lt;br /&gt;&lt;br /&gt;Here, in the above code we have two constructors but our function signatures are different in both Constructors. In the first constructor the Function signature or parameter is void and in the second one we have three parameters one Integer and two strings. So for invoking the second constructor we must have to pass values to the object.&lt;br /&gt;&lt;br /&gt;Eg&lt;br /&gt;--------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//Invokes the Default Constructor&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;HelloWorld hwObj=new HelloWorld();        &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//This invokes the Second constructor&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;HelloWorld hwObj1=new HelloWorld(20,&quot;SMILU&quot;,&quot;TPRA&quot;);  &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;--------------------------&lt;br /&gt;&lt;br /&gt;Like this we can have many constructors inside a Class.&lt;br /&gt;&lt;br /&gt;Now, if in the case we have Static class and variables and have to initialize those variables we need another type of constructors called Static constructors.&lt;br /&gt;Static constructors are used for initializing values inside Static classes. We cannot have instance constructors inside the static classes.&lt;br /&gt;&lt;br /&gt;For Creating a static constructor we can use the static keyword.&lt;br /&gt;-----------------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;static class HelloWorld&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;static int i;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;static HelloWorld()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    i=10;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;------------------------------------------&lt;br /&gt;&lt;br /&gt;These are the types of constructors in C#.</description><link>http://csharpasp.blogspot.com/2008/11/c-constructors.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-7583335883882785176</guid><pubDate>Thu, 06 Nov 2008 05:17:00 +0000</pubDate><atom:updated>2008-11-06T10:49:57.114+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Object</category><title>What is an Object?</title><description>What is an object? &lt;br /&gt;In simple words we can say an Object as an &quot;Instance of a Class.&quot; Without Objects we cannot say a Class is Existing.&lt;br /&gt;An object is a combination of messages and data. Objects can receive and send messages and use messages to interact with each other. The messages contain information that is to be passed to the recipient object.&lt;br /&gt;Look at the program given below:&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;---------------------------------------&lt;br /&gt;    &lt;span style=&quot;font-family: courier new;&quot;&gt;namespace prime_no&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        class prime&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            int num;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            public void acceptNo()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                Console.WriteLine(&quot;Enter a number:&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                num = Convert.ToInt32(Console.ReadLine());&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                Console.WriteLine(&quot;\n&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            public void primeNosTill()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                int i, j;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                bool answer = false;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                Console.WriteLine(&quot;The prime numbers till entered number are: &quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                for (i = 2; i &lt;= num; i++)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    for (j = 2; j &lt;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        if (i % j == 0)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                            answer = true;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                            break;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    if (answer == false)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        Console.WriteLine(i);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        answer = false;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            class execute&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                public static void Main(string[] a)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    prime primeNo = new prime();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    primeNo.acceptNo();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    primeNo. primeNosTill();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                    Console.Read();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;---------------------------------------&lt;br /&gt;&lt;br /&gt;The prerequisite of object creation is a class i.e. you can only create an object of a class. For the declaration of a class, the class keyword is used.  In the above code, class keyword defines the class prime. The braces know as delimiters, are used to indicate the start and end of a class.&lt;br /&gt;The functions of a class are called member functions. A function is a set of statements that performs a specific task in response to a message. Member functions are declared inside the class.  The function declaration introduces the function in the class and function definition contains the function code. The two member functions in the above code are acceptNo and primeNosTill.&lt;br /&gt;The execute class is declared with the Main() method. The execute is used as a class from where the prime class can be instantiated. To use the members of the class, the object of that must be created.&lt;br /&gt;The above code contain class prime and the object has been named primeno.&lt;br /&gt;prime primeno = new prime();&lt;br /&gt;The member functions (acceptNo and primeNosTill), can be accessed through the object (primeno) of the class prime using “.” operator.&lt;br /&gt;primeno.acceptNo();&lt;br /&gt;primeno. primeNosTill();&lt;br /&gt;&lt;br /&gt;The acceptNo function accepts the number from the user and primeNosTill function displays all the prime numbers till the number entered by the user.</description><link>http://csharpasp.blogspot.com/2008/11/what-is-object.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-1626811750001607798</guid><pubDate>Thu, 31 Jul 2008 06:22:00 +0000</pubDate><atom:updated>2013-01-20T13:36:38.533+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Access Specifier(s)</category><title>Access Specifiers in C#</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
What is an access specifier?&lt;br /&gt;
&lt;br /&gt;
An access specifier defines the scope of a class member. A class member refers to the variables and functions in a class. A program can have many classes. The programmer gets the privilege to decide the of use access specifier to implement encapsulation and abstraction in C#.&lt;br /&gt;
&lt;br /&gt;
So, when we use Access Specifiers in C# they help the other class members to know how they can access the methods or variables declared/defined inside another class.&lt;br /&gt;
&lt;br /&gt;
C# supports five types of access specifiers to tell the extent of visibility of a class member. They are:-&lt;br /&gt;
&lt;ul style=&quot;font-weight: bold;&quot;&gt;
&lt;li&gt;public, &lt;/li&gt;
&lt;li&gt;private, &lt;/li&gt;
&lt;li&gt;protected, &lt;/li&gt;
&lt;li&gt;internal and &lt;/li&gt;
&lt;li&gt;protected internal. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Let&#39;s now go into detail.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #ff6600; font-size: 130%; font-weight: bold;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff6600; font-size: 130%;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The public access specifier in C# allows a class to expose its member variables and member functions to other functions and objects. So any member declared public can be accessed outside the class also.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s check an example for this..&lt;br /&gt;
----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;using System;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;namespace HelloWorld&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    class hello&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        public int iNum1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    class MyMainClass&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    static void Main(string[] args)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        hello HelloObject=new hello();        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        HelloObject.iNum1=10; &lt;span style=&quot;color: #33cc00;&quot;&gt;/* since variable iNum1 is public it can be accessed in other classes also*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        Console.WriteLine(HelloObject.iNum1);        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #ff6600; font-size: 130%; font-weight: bold;&quot;&gt;private:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The private access specifier in C# is just opposite to the public access specifier. That is it allows a class to hide its member variables and member functions from other class objects and functions. So it is not visible outside the class. By default, the access specifier is private; if public, private or protected is not specified.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s check an example for this..&lt;br /&gt;
----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;using System;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;namespace HelloWorld&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    class hello&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        public int iNum1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        private int iNum2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        public hello()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;            iNum1=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;            iNum2=10;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    class MyMainClass&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    static void Main(string[] args)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        hello HelloObject=new hello();        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #33cc00; font-family: courier new;&quot;&gt;        //CORRECT METHOD&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        HelloObject.iNum1=10;    //Here since variable iNum1 is public it can be accessed in other classes also&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;span style=&quot;color: red;&quot;&gt;//WRONG METHOD&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        HelloObject.iNum2=20; &lt;span style=&quot;color: red;&quot;&gt;/*This line will return an Error since the access to this variable is Private. So it cannot be accessed outside the class*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        Console.WriteLine(HelloObject.iNum1);        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #ff6600; font-size: 130%; font-weight: bold;&quot;&gt;protected:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The protected access specifier in C# allows a class to hide its member variables and member functions from other class objects and functions, except the child class. This access specifier is used when we need to use Inheritance in the program.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s check an example for this..&lt;br /&gt;
----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;using System;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;namespace HelloWorld&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    class hello&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        public int iNum1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        protected int iNum2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    class world : hello&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    public int AddDetails()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    iNum1=20;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    iNum2=10;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    return iNum1+iNum2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    class MyMainClass&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    static void Main(string[] args)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        world worldObject=new world();        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        worldObject.iNum1=50; &lt;span style=&quot;color: #33cc00;&quot;&gt;//Line 1 No Error&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        worldObject.iNum2=10; &lt;span style=&quot;color: red;&quot;&gt;//Line 2 Error&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        Console.WriteLine(worldObject.AddDetails().ToString());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;        &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;    }    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------&lt;br /&gt;
In the above case we have not called the object of the class hello. But we have inherited the class hello to the class world. So all the public and protected members inside the class is accessible inside the derived class also. We don&#39;t need to create objects for the base class to access the variables or methods we have in our parent class.&lt;br /&gt;
Now inside the &lt;span style=&quot;font-family: courier new;&quot;&gt;Main()&lt;/span&gt; function we are assigning value to iNum1 and iNum2. Line 1 will not return any error because the variable iNum1 is public. So, it can be accessed from anywhere in the program, but Line2 will give an Compilation Error saying &quot;iNum2 is inaccessible due to protection level&quot;. This is because access of the variable iNum2 is set to protected. The protected members can only be accessed inside the Child class and its parent class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #ff6600; font-size: 130%; font-weight: bold;&quot;&gt;internal:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The internal access specifier in C# allows a class to expose its member variables and member functions to other function and objects. It can be accessed from any class or method defined with the application in which the member is defined. The default access specifier is internal for a class.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #ff6600; font-size: 130%; font-weight: bold;&quot;&gt;protected internal:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The protected internal access specifier in C# allows methods or member variables accessible to a class and its derived classes inside the same &lt;span style=&quot;font-family: courier new;&quot;&gt;assembly&lt;/span&gt; or &lt;span style=&quot;font-family: courier new;&quot;&gt;namespace&lt;/span&gt; within a file. These members cannot be accessed from class inside another assembly or a file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lets now understand the above with an example:&lt;br /&gt;
----------------------------------------------------------------&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;using System;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;class Student&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;private string sAddress;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;protected string sPhNo;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;protected internal long iZipCode;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;void Hello()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(“Hello World!”);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;internal void Hello2()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(“Hello Student!”);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;public  void SetAddress()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(“Enter your Address:”)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;sAddress = Console.ReadLine();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;public  void SetPhNo()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(“Enter your Phone Number:”)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;sPhNo = Console.ReadLine();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt; public void SetZipCode()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(“Enter the Zip Code: “);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;iZipCode =Convert.ToInt64(Console.ReadLine());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;public void DisplayStudent()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(“The Address is: {0}”, sAddress);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;class Display&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;static void Main(string[] args)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Student John = new Student();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(John.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;sPhNo&lt;/span&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;); &lt;span style=&quot;color: #33cc00;&quot;&gt;       &lt;span style=&quot;color: red;&quot;&gt;//Error: Protected members cannot be accessed &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;John.SetAddress();    //public members can be accessed outside the class definition &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;John.SetPhNo();    &lt;span style=&quot;color: #33cc00;&quot;&gt;//public members can be accessed outside the class definition &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(John.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;iZipCode&lt;/span&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;);    //error: protected internal members cannot be accessed outside the class definition &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;John.SetZipCode(); &lt;span style=&quot;color: #33cc00;&quot;&gt;   //public members can be accessed outside the class definition &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;John.DisplayStudent();    &lt;span style=&quot;color: #33cc00;&quot;&gt;// public members can be accessed outside the class definition &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(John.sAddress); &lt;span style=&quot;color: red;&quot;&gt;       //error: private members cannot be accessed outside the class definition &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;John.Hello();    &lt;span style=&quot;color: red;&quot;&gt;//error: private members cannot be accessed outside the class definition &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;John.Hello2(); &lt;span style=&quot;color: #33cc00;&quot;&gt;    //displays Hello student!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.ReadLine();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
That&#39;s how access specifiers work.&lt;/div&gt;
</description><link>http://csharpasp.blogspot.com/2008/07/access-specifiers-in-c.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-919696070690479165</guid><pubDate>Wed, 30 Jul 2008 11:09:00 +0000</pubDate><atom:updated>2013-01-20T13:20:00.865+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Function Overloading</category><title>Function Overloading</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Function overloading is the process of having the same name for functions but having different parameters(function signatures), either in number or in type. Function overloading reduces the complexity of a program. Function overloading helps the user to use functions without changing its name or the return type. To overload a function we need to change the parameters inside the Function. The parameters/function signature(s) should not be the same for another function which need to overloaded.&lt;br /&gt;
-------------------------------------------------&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;class MethodOverloading&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;//Method one&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;public void Add(int i, int j)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(i+j);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;//Method Two&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;public void Add(string s, string k)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;Console.WriteLine(s+k);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
--------------------------------------------------&lt;br /&gt;
Here in the above code we have two methods with the same name Add. This method is overloaded since the signatures inside it changes in the second method. In the first method we have passed two Integer values as parameters and in the second method we have passed two string values into the method. Now when we call this method, if we are passing two integer values to the method then the first method will be invoked and will be adding the two integers and showing the result to us. In the other case if we are passing two String values into the same function the second method will be invoked and it will be concatenating the two strings and the concatenated string is displayed.&lt;br /&gt;
Here when we used function overloading it does not vary in the return type. But the behavior has changed according to the values we pass to the functions.&lt;br /&gt;
&lt;br /&gt;
In the above case Method 1 and Method 2 have the same return Type but are varied in the signature.&lt;br /&gt;
Method 1 has two integer parameter and Method 2 has two string parameters.&lt;br /&gt;
&lt;br /&gt;
Now we’ll check some more examples for function overloading..&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;class MethodOverloading&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;public int Display(int i)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;return i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;public int Display(int j, int k)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;return j+k;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;public int Display(int l, int m,int n)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;return (l+m-n);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here in the above cases in all the functions we have integer parameters. These are also overloaded because the parameters passed to each method vary in number ie; the First method has only one parameter; the second have two parameters and the third have three parameters.&lt;/div&gt;
</description><link>http://csharpasp.blogspot.com/2008/07/function-overloading.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-1744754479975363172</guid><pubDate>Mon, 28 Jul 2008 12:05:00 +0000</pubDate><atom:updated>2008-07-31T10:00:42.937+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# Method</category><title>Methods with return type in C#</title><description>Here in this topic we will check how we can create Methods with a return type.&lt;br /&gt;&lt;br /&gt;We use methods with a return type when we need a method to return some values to the place from which the method has been called. Return type can be of any type. If we need to return and Integer we can use int keyword. Likewise we can return string, float, double, Class etc...&lt;br /&gt;&lt;br /&gt;While we create a method with a return type it should have the keyword &quot;return&quot; followed by the value of the type the method returns...&lt;br /&gt;If the method is returning an integer we can write it as return 0. Because 0 is an integer.&lt;br /&gt;&lt;br /&gt;Let&#39;s check an example for methods with a return type...&lt;br /&gt;-----------------------------------------&lt;br /&gt;Example 1:-&lt;br /&gt;------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//Method with an integer return type&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;public int Add()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;int &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;iResult&lt;/span&gt;=10+20;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;return &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;iResult&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;------------&lt;br /&gt;Here we have used the&lt;span style=&quot;font-family:courier new;&quot;&gt; return&lt;/span&gt; keyword to return the value inside the integer variable &lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;iResult&lt;/span&gt;&lt;/span&gt;. So if we call the method &lt;span style=&quot;font-family:courier new;&quot;&gt;Add()&lt;/span&gt; we will be getting the sum of the two numbers.&lt;br /&gt;&lt;br /&gt;Example 2:-&lt;br /&gt;------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//Method with a string return type&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;public string &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;HelloWorld&lt;/span&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;return &quot;Hello World!&quot;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;------------&lt;br /&gt;In the above example we have created a method with a string return type. Here we are returning the string &quot;Hello World!&quot;.&lt;br /&gt;-----------------------------------------&lt;br /&gt;&lt;br /&gt;While we call a method with a return type it should also be stored into the same type. Like wise we can create method(s) with return types.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 102, 0);font-size:130%;&quot; &gt;&lt;br /&gt;Now we&#39;ll see methods with parameters that return values.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Parameters are used inside a method to pass values to a method at the time of call. We must specify the types of variables inside the method parenthesis for accepting values. Parameters which we declare inside the method parenthesis is also known as Function signatures. While we pass values to methods which accepts values, it should be passed in the exact order in which we have defined that method.&lt;br /&gt;&lt;br /&gt;Let&#39;s check a method with parameters:-&lt;br /&gt;-----------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;class Calculator&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;public int &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_4&quot;&gt;AddNumber&lt;/span&gt;(int &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_5&quot;&gt;num&lt;/span&gt;1, int &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_6&quot;&gt;num&lt;/span&gt;2)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt; int result;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt; result = &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_7&quot;&gt;num&lt;/span&gt;1 + &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_8&quot;&gt;num&lt;/span&gt;2;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt; return result;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;-----------------------------------------&lt;br /&gt;&lt;br /&gt;Here &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_9&quot;&gt;AddNumber&lt;/span&gt; is the name of the method. Since the access specifier is public, the method can be accessed from outside the class also.  The method is taking two integers as the parameters and returning the value stored in the result variable. So, we must have to pass two integer values while we call this method. The values passed to this method will be stored in &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_10&quot;&gt;num&lt;/span&gt;1 and &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_11&quot;&gt;num&lt;/span&gt;2 variables.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_12&quot;&gt;eg&lt;/span&gt;:-&lt;br /&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;static void Main(string[] &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_13&quot;&gt;args&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;   int &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_14&quot;&gt;iResult&lt;/span&gt;=&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_15&quot;&gt;AddNumber&lt;/span&gt;(10,20);&lt;br /&gt;  Console.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_16&quot;&gt;WriteLine&lt;/span&gt;(i);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Here we have called the method &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_17&quot;&gt;AddNumber&lt;/span&gt;. Since the method returns an integer it is assigned to an integer variable. Likewise we should do in each function which have return type..&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;</description><link>http://csharpasp.blogspot.com/2008/07/methods-with-return-type-in-c.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-40769114097132915</guid><pubDate>Mon, 28 Jul 2008 04:33:00 +0000</pubDate><atom:updated>2008-07-28T10:19:48.894+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C# Function</category><category domain="http://www.blogger.com/atom/ns#">C# Method</category><title>C# Functions/Methods</title><description>A function/method is a set of one or more program statements, which can be executed by referring to the function/method name.&lt;br /&gt;&lt;br /&gt;When a complex application is divided into methods, code becomes more flexible, easy to maintain and to debug. For performing repetitive tasks methods are useful. Methods allow breaking an application into discrete logical units, which makes the application more readable. Code written in a method can be reused since it can be executed any number of times by calling the method itself with little or no modification.&lt;br /&gt;&lt;br /&gt;The syntax of defining a method is given below:&lt;br /&gt;-------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&lt;&gt;  &lt;return&gt;  &lt;method&gt; (Parameter list)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;      //Method body&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;-------------------------------------------------&lt;br /&gt;&lt;br /&gt;Let&#39;s look at an example:&lt;br /&gt;-------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;public void Hello()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;    Console.WriteLine(&quot;Hello World!&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;-------------------------------------------------&lt;br /&gt;&lt;br /&gt;Here &quot;public&quot; keyword shows the access to this method/function. When we use public access specifier the method can be accessible inside and outside the class.&lt;br /&gt;&lt;br /&gt;&quot;&lt;span style=&quot;font-family: courier new;&quot;&gt;void&lt;/span&gt;&quot; refers to the return type of the method. Void means nothing should be returned and &lt;span style=&quot;font-family: courier new;&quot;&gt;Hello()&lt;/span&gt; is the function/method name. Functions/methods will be having opening and closing parenthesis.</description><link>http://csharpasp.blogspot.com/2008/07/c-functionsmethods.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-1632138440431671446</guid><pubDate>Wed, 23 Jul 2008 08:55:00 +0000</pubDate><atom:updated>2008-07-23T15:25:59.006+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arrays</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">C# Array</category><title>C# Array</title><description>Arrays are collection of Elements having the same DataType stored in Consecutive memory locations. Arrays can only store data of the same type ie, if it’s an integer array the array can only store Integer values. It will not allow any other types to be stored.&lt;br /&gt;&lt;br /&gt;Let’s see how we can declare an array in C#.&lt;br /&gt;&lt;br /&gt;If you need to create a character array to store ten elements then we can declare it like this…&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;char[] cArr=new char[10];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To pass values  to an Array at the time of declaration we can write an array like this…&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;char[] cArr={‘H’,’e’,’l’,’l’,’o’,’!’};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since this is a character array we can only pass single values.&lt;br /&gt;&lt;br /&gt;We’ll now see how we create arrays for each type..&lt;br /&gt;&lt;br /&gt;Integer Array in C#&lt;br /&gt;--------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;int[] iArr=new int[10];&lt;/span&gt;&lt;br /&gt;or&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;int[] iArr={1,2,3,4,5};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;String Array in C#&lt;br /&gt;-------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;string[] sArr=new string[10];&lt;/span&gt;&lt;br /&gt;or&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;string[] sArr={“Hello”,”world”};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In an array.. items are stored in index of the array. For retrieving values in an array we must mention the index. Always the first index of an array will be &lt;span style=&quot;font-weight: bold;&quot;&gt;0&lt;/span&gt; and the last index will be the size of the index minus &lt;span style=&quot;font-weight: bold;&quot;&gt;1&lt;/span&gt; ie if the size is 10 for an array the last index will be 9.&lt;br /&gt;&lt;br /&gt;In the above case of the string array the values “Hello” and &quot;World&quot; will be stored in two index of the array. The index of the “Hello” will be 0 and “World” will be 1.&lt;br /&gt;If we need to just print hello on the screen then we must have to write..&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;Console.WriteLine(sArr[0]);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here in the above code sArr is the Array name and 0 is used to mention the Element in which index should be selected likewise if we need to print World then we must have to say sArr[1]..&lt;br /&gt;&lt;br /&gt;Now we will check how we can print all items in an Array. For doing this we can use two types of loops.&lt;br /&gt;The first one is for loop…&lt;br /&gt;&lt;br /&gt;For loop to display Elements in an Array&lt;br /&gt;-----------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;for(int i=0;i&lt;sarr.length;i++)&gt;&lt;/sarr.length;i++)&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;Console.WriteLine(sArr[i]);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here in the above case we have written int i=0 in the for loop and for printing we have just written it&lt;span style=&quot;font-family:courier new;&quot;&gt; sArr[i]&lt;/span&gt; here we says I because its having the values from 0 to the value less than the length of the array.&lt;br /&gt;&lt;br /&gt;So, when the loop works for the first time its value will be 0 so it prints “Hello” and when it goes for the second time the value is 1 so it prints “World” and when it goes for the third time the value is not less than 2 ie the length is two for the array and now the value of I is also two so it terminates…..&lt;br /&gt;&lt;br /&gt;When we use for loop it have a drawback ie we must know the size of the array. For curing that we have another loop ie foreach loop in c#.&lt;br /&gt;&lt;br /&gt;In a foreach loop its not necessary to know the size of the array…&lt;br /&gt;We’ll just see one foreach loop for the same array…&lt;br /&gt;&lt;br /&gt;Foreach loop to display items in an array..&lt;br /&gt;-------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;foreach(string s in sArr)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;Console.WriteLine(s);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the above code we are using foreach loop if just see the two loops itself we can see the difference. In a Foreach loop we don’t need to mention the array size to be printed…. When we run the foreach loop it will store the first element in string variable s and prints it and next time it will automatically gets incremented to the next element and prints the second element…. Likewise it will run till the array terminates..</description><link>http://csharpasp.blogspot.com/2008/07/c-array.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-3651715776351374699</guid><pubDate>Wed, 04 Jun 2008 06:25:00 +0000</pubDate><atom:updated>2008-06-18T15:25:28.195+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Loops</category><title>Loops used in C# .net</title><description>Loops are used to run a set of codes repeatedly.&lt;br /&gt;&lt;br /&gt;Loops we use in C# are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;while Loop,&lt;/li&gt;&lt;li&gt;do...while Loop &lt;/li&gt;&lt;li&gt;for Loop and&lt;/li&gt;&lt;li&gt;foreach Loop&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;C# while Loop&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;While loop and do..while loops are used in conditions like the Number of iterations are Unkown ie, the number of times the loop should work is unknown. While loop works only if the Condition gets true.&lt;br /&gt;&lt;br /&gt;Let&#39;s check the structure of a while loop...&lt;br /&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;while(condition==true)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    //Statements&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;br /&gt;While loop only works if the Condition is true. Here in this case if the condition doesnt gets false it will become an infinite loop.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;C# do ... while loop&lt;/span&gt;&lt;br /&gt;-----------------------------------&lt;br /&gt;while loop have a disadvantage that it dosnt gets executed even for one time if the condition is false. To overcome this problem we have do while loop.&lt;br /&gt;&lt;br /&gt;do...while loop is also like a while loop but it gets into the loop for the first time even if the condition is false. But from the second time if the loop wants to work the while condition checks for the condition to become true.&lt;br /&gt;&lt;br /&gt;The structure of a do...while loop is...&lt;br /&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    //Statements&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}while(Condition==true);&lt;/span&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;br /&gt;Here from the second time it works only if the Condition or the testexpression becomes true..... In this loop also the number of iterations is not Known.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;C# for loop....&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For loop is used when the number of iterations is fixed. If we know how many times the loop needs to work we use the For Loop.&lt;br /&gt;&lt;br /&gt;The structure of a for loop is...&lt;br /&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;for(initialisation;testexpression;increment/decrementoperator)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    //statements&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;br /&gt;Here in this case the initialisation is the place we declare or define some values to the variables which should be used inside the loop...&lt;br /&gt;Testexpression checks the condition of the loop ie it defines the number of iteration of the Loop...&lt;br /&gt;increment/decrement This is used to make the condition of the loop to become false so the loop gets stopped at certain interval.&lt;br /&gt;&lt;br /&gt;I&#39;ll show you an example to get the first ten numbers...&lt;br /&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;for(int i=1;i&lt;=10;i++)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    Console.WriteLine(i);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;The above loop will print the first ten numbers. Here itself if we loop at it we can see the Initialisation as int i=1. This is I am declaring a variable with the name i and setting its value as 1. In the second expression I have given a Condition asking whether the variable i have the value less than or equal to 10 and in the third case when each time the loop works the value of variable i gets added by 1. So when it becomes 11 the loop gets terminated.&lt;br /&gt;&lt;br /&gt;Working of a for loop...&lt;br /&gt;----------------------------------&lt;br /&gt;While we use a for loop... the initialisation expression is only called for the first time. When the loop starts to run from the second time it doesn&#39;t enter to the Initialisation expression instead it increments the value of the variable and checks whether the test expression is true or false.&lt;br /&gt;&lt;br /&gt;Step 1: Initialisation&lt;br /&gt;Step 2: Condition&lt;br /&gt;Step 3: Increment or Decrement&lt;br /&gt;&lt;br /&gt;For the first time it calls STEP 1&lt;br /&gt;then goes to the Step 2 and enters into the loop body&lt;br /&gt;&lt;br /&gt;From the second time when it comes to the loop it goes to Step 3 and then to Step 2..... and if it returns true it enters the loop body...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;C# foreach loop...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;foreach loop is a new loop introduced in C#. This loop is same as for loop but this loop will be commonly used for working with arrays collections etc.. If we are using a for loop for displaying the values of an array we need to know the size of the array. But in the case of a foreach loop the size of the array need not be known. foreach loop automatically takes the size of the array and calculates it....&lt;br /&gt;&lt;br /&gt;Let&#39;s see an example for that...&lt;br /&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;foreach(DataType var in DataTypeCollection)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    //Statements&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;} &lt;/span&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;In this type of loop we will be creating a variable which will be the same as the collection datatype to be worked with. If you are going to print all elements of an array collection then the variable should be on the DataType that can store the value of the Array. Like this we can run this for loop even for Controls in .net like ListBox, ComboBox etc.....&lt;br /&gt;&lt;br /&gt;Just check how it works.....&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;char[] arr=new char[10];&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 204, 0);font-family:courier new;&quot; &gt;//I need to print all the elements in this array for doing that we can use a foreach loop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;for(char c in arr)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    Console.WriteLine(c);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;----------------------------------&lt;br /&gt;&lt;br /&gt;Here in the above case it will create a Character variable &quot;c&quot; and when the loop starts to work each time it will assign value at the appropriate index to the variable and print it....</description><link>http://csharpasp.blogspot.com/2008/06/loops-used-in-c-net.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-3167992378888887001</guid><pubDate>Tue, 20 May 2008 02:38:00 +0000</pubDate><atom:updated>2008-06-15T12:09:43.795+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Conditional Operators</category><title>Conditional Operators in C#</title><description>&lt;span style=&quot;color: rgb(255, 102, 0);font-size:130%;&quot; &gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;if-else constructor&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;if-else constructor is used to check conditions using. if-else will be always having two conditions True or False.&lt;br /&gt;&lt;br /&gt;Let&#39;s see a simple if-else constructor.&lt;br /&gt;&lt;br /&gt;--------------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;if(Condition)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//    true part;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//    false part;    &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;---------------------------------------&lt;br /&gt;&lt;br /&gt;In the above set of code we are using an if-else constructor to check a condition. Now if the Condition we have typed inside the if is TRUE it will get inside the True part of the constructor and if the condition is false it will enter inside the false part. The CONDITION may Contain  operators like Arithmetic, Relational and Logical for checking different types of conditions.&lt;br /&gt;&lt;br /&gt;Now, Lets check a real problem with if-else....&lt;br /&gt;&lt;br /&gt;I have two integer variables nameley iNum1 and iNum2. I am going to check which number is bigger.&lt;br /&gt;&lt;br /&gt;----------------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//Assigning values for the two variables&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;iNum1=10;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;iNum2=20;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//Starting the condition&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;if(iNum1&gt;iNum2)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    Console.WriteLine(&quot;The condition is TRUE&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    Console.WriteLine(&quot;The condition is FALSE&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;----------------------------------------&lt;br /&gt;&lt;br /&gt;Here iNum1 is assigned a value of 10 and iNum2 is assigned a value of 20. Now when the program gets executed the condition will be returning false because iNum1 variable is smaller than iNum2.&lt;br /&gt;So, it will print &quot;The condition is FALSE&quot; on the screen.&lt;br /&gt;&lt;br /&gt;Like this if the condition gets true it will enter into the true part ie the &quot;if&quot; body of the program and if condition gets false it enters into the else part of the Program.&lt;br /&gt;&lt;br /&gt;We can also have multiple nested if conditions on a single if-else constructor. Let&#39;s check another example of checking which number is bigger out of three numbers.&lt;br /&gt;&lt;br /&gt;I have three variables namely iNum1,iNum2,iNum3.&lt;br /&gt;&lt;br /&gt;------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;if(iNum1&gt;iNum2 &amp;amp;&amp;amp; iNum1&gt;iNum3)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    Console.WriteLine(&quot;iNum1 is the biggest number&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;else if(iNum2&gt;iNum1 &amp;amp;&amp;amp; iNum2&gt;iNum3)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    Console.WriteLine(&quot;iNum2 is the biggest number&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    Console.WriteLine(&quot;iNum3 is the biggest number&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;------------------------------------------&lt;br /&gt;&lt;br /&gt;Here in the above code we are using Relational and Logical operators. When we have multiple conditions like this we can use operators as shown above.&lt;br /&gt;We have actually three conditions here so we can use Nested if&#39;s like this. When the if condition gets false it will enter the else if condition and when and only else if condition gets false it will enter the else condition of the program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is how we use if-else constructor in programs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;-------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 102, 0);font-size:130%;&quot; &gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;switch-case conditions.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;switch case conditional statements are used to check conditions according to the incoming values to the variables. Here we will switch a variable and inside the cases we will check for the conditions.......&lt;br /&gt;&lt;br /&gt;Let&#39;s see and example for this...&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;switch(iMonth)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    case 1:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        Console.WriteLine(&quot;January&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        break;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    case 2:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        Console.WriteLine(&quot;February&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        break;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    case 3:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        Console.WriteLine(&quot;March&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        break;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    default:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        Console.WriteLine(&quot;Please enter a Valid number&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        break;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Here in the above code we are switching a variable inside the switch body. Now the switch will check for cases with the value inside the switch variable. If it matches any of the value inside any case it will get into the Case body.&lt;br /&gt;&lt;br /&gt;If we pass a value 2 into the variable iMonth the switch will get into the case 2: and print &quot;February&quot;.&lt;br /&gt;&lt;br /&gt;Since we are using integer Datatype we can straight away write the numbers in the cases with a single space seperated.&lt;br /&gt;&lt;br /&gt;The &quot;default&quot; statement gets printed in the case if a number(value) which is not the case conditions is assigned to the switch variable.&lt;br /&gt;&lt;br /&gt;Now if you are passing a Character Datatype you must write the cases like this...&lt;br /&gt;--------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;case &#39;A&#39;:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//statements&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;break;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;case &#39;C&#39;:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;//statements&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;break;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;} &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;---------&lt;br /&gt;&lt;br /&gt;and in the case of strings you can write the cases like this....&lt;br /&gt;&lt;br /&gt;---------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;case &quot;C#.net&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;Console.WriteLine(&quot;Windows programming&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;break;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;br /&gt;case &quot;ASP.net&quot;&lt;br /&gt;{&lt;br /&gt;Console.WriteLine(&quot;Web Programming&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;---------&lt;br /&gt;&lt;br /&gt;you must have checked &quot;break&quot; statements after each case and default statements.&lt;br /&gt;We must use break statements inside this just because it may jump into next Case. In C# break statements are compulsory and if we dont use break statements it will return an error.&lt;br /&gt;&lt;br /&gt;We can have multiple cases in the switch statement but only a single default statement in the switch statement....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That&#39;s all about switch case and If else conditions.........</description><link>http://csharpasp.blogspot.com/2008/05/conditional-operators-in-c.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-4165080182638296202</guid><pubDate>Tue, 18 Mar 2008 03:22:00 +0000</pubDate><atom:updated>2008-03-18T09:14:31.574+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Operators in C#</category><title>What are operators?</title><description>Operators are used to do perform some operations on variables.&lt;br /&gt;&lt;br /&gt;We have four types of operators in C#.&lt;br /&gt;&lt;ul style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Arithmetic Operators,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Relational operators ,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Logical operators and&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Unary operators&lt;/span&gt;.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 102, 0);&quot;&gt;Arithmetic Operators :-&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Arithmetic Operators are used to do mathematical operations&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The basic arithmetic Operators are&lt;br /&gt;&lt;br /&gt;+ for addition&lt;br /&gt;- for subtraction&lt;br /&gt;* multiplication&lt;br /&gt;/ division&lt;br /&gt;% modulo operator(This operator is used to return the Remainder of two numbers).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 102, 0);font-size:130%;&quot; &gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Relational Operators:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Relational operators are mainly used for checking conditions between two or more variables.&lt;br /&gt;&lt;br /&gt;The relational operators we use in C# are..&lt;br /&gt;&lt;br /&gt;&gt; Greater than(Checks which number is greater)&lt;br /&gt;&lt;&gt;= Greater than or equal to(Checks whether the given number is greater than or equal to the second number)&lt;br /&gt;&lt;= Less than or equal to(Checks whether the given number is less than or equal to the second number) == Equal to(Checks whether the second number is equal to the first number) != not equal to(Checks whether the second number is not equal to the first number)   &lt;span style=&quot;font-weight: bold;&quot; size=&quot;4&quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 0);&quot;&gt;Logical Operators :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Logical operators are used to check logical conditions with a block of two or more relations&lt;br /&gt;Logical operators we use in C# are AND, OR and NOT.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;AND operator is represented with &amp;amp;&amp;amp; (two ampersand)&lt;/li&gt;&lt;li&gt;OR operator is represented with || (two pipes) and&lt;/li&gt;&lt;li&gt;NOT operator is represented with !(Exclamation).&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;eg:-&lt;br /&gt;((iNum1&gt;iNum2) &amp;amp;&amp;amp; (iNum1!=0))&lt;br /&gt;In the above example we are checking whether the first variable is greater than the second variable AND iNum1 is not equal to ZERO. Here if both the conditions are true only the condition will execute.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;How Logical operators work.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 0); font-weight: bold;&quot;&gt;AND(&amp;amp;&amp;amp;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;amp;&amp;amp;(AND) operator becomes true only if all the conditions are true. If any of the conditions are false &amp;amp;&amp;amp; operator returns false.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 102, 0);&quot;&gt;OR(||)&lt;/span&gt;&lt;br /&gt;||(OR) operator becomes false only if all conditions are false. If any of the condition becomes true || operator becomes true.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 0); font-weight: bold;&quot;&gt;NOT(!)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;!(NOT) operator becomes true if the condition is false and false if the condition is true.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 102, 0);font-size:130%;&quot; &gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Unary Operators&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 0, 51);font-size:100%;&quot; &gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Unary operators are used to add or subtract a variable by 1.&lt;br /&gt;We  have mainly two types of  unary operators&lt;br /&gt;Increment and&lt;br /&gt;Decrement.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Increment  operator is  represented by  ++  and decrement operator is  represeted by --.&lt;br /&gt;Increment operator adds a variable by one and decrement operator subracts a variable value by&lt;br /&gt;one.&lt;br /&gt;&lt;br /&gt;i++, i--.&lt;br /&gt;&lt;br /&gt;Unary operators can be used in two ways POSTFIX and PREFIX.&lt;br /&gt;&lt;br /&gt;In a postfix notation the unary operator will be placed after the variable(i++)&lt;br /&gt;In a prefix notation the unary operator will be placed before the variable(++i)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 102, 0);font-size:130%;&quot; &gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Assignment Operator&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot; &gt;An&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:85%;&quot; &gt; assignment operator is used to assign a value to a variable. An = (equal to) symbol is known as an assignment operator.&lt;br /&gt;&lt;br /&gt;int i=10;&lt;br /&gt;means assigning the integer variable i a vlaue of 10.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;</description><link>http://csharpasp.blogspot.com/2008/03/what-are-operators.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-56086989582011115</guid><pubDate>Tue, 18 Mar 2008 03:19:00 +0000</pubDate><atom:updated>2008-03-18T08:52:36.830+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Variables</category><title>What is a Variable?</title><description>&lt;span style=&quot;font-weight: bold; color: rgb(255, 102, 0);&quot;&gt;Variable&lt;/span&gt; is a name given to a memory location.&lt;br /&gt;Variable will be having a memory address value&lt;br /&gt;&lt;br /&gt;For eg:-&lt;br /&gt;int iNum1&lt;br /&gt;char cName&lt;br /&gt;float fNum etc..&lt;br /&gt;&lt;br /&gt;Here,&lt;span style=&quot;font-weight: bold;&quot;&gt; int,char,float&lt;/span&gt; represents the &lt;span style=&quot;font-weight: bold;&quot;&gt;Data type&lt;/span&gt; to be used and &lt;span style=&quot;color: rgb(255, 102, 0);&quot;&gt;iNum1,cName,fNum&lt;/span&gt; are the &lt;span style=&quot;font-weight: bold;&quot;&gt;variable&lt;/span&gt; names given for those DataTypes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Rules For Declaring a Variables :-&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A Variable name Should Start with an Alphabet&lt;/li&gt;&lt;li&gt;Key Words representing the program should not be used as variable name.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;for eg: numeric, int, console etc.. should not be used.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Special characters except an underscore( _ ) are not allowed&lt;/li&gt;&lt;li&gt;Variable names should not start with a number.&lt;/li&gt;&lt;/ul&gt;</description><link>http://csharpasp.blogspot.com/2008/03/what-is-variable.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-1850361108086956819</guid><pubDate>Fri, 07 Mar 2008 10:49:00 +0000</pubDate><atom:updated>2008-03-07T16:55:03.029+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Data types</category><title>Data Types in C#</title><description>As of now we have studied how to start program using C#.&lt;br /&gt;&lt;br /&gt;Now we will check some other programs in C#.&lt;br /&gt;&lt;br /&gt;What do you mean by a &lt;span style=&quot;color: rgb(255, 102, 0); font-weight: bold;&quot;&gt;Data Type&lt;/span&gt;?&lt;br /&gt;In simple words Data Type means the type of data. The data may be mainly of three types. They are&lt;br /&gt;Integer, Character and Float. These are also called base data types.&lt;br /&gt;&lt;br /&gt;Integer are used to store integers or numbers without decimals.&lt;br /&gt;eg:- 1,123,1452,9999 etc...&lt;br /&gt;&lt;br /&gt;Characters are used to accept letters. Basically a character Data type can accept only one byte. So, it will store only one Letter.&lt;br /&gt;&lt;br /&gt;eg:- a,A,b,c,d etc....&lt;br /&gt;If we write -AB- it will return an error...&lt;br /&gt;&lt;br /&gt;Float is used to accept Floating numbers or numbers with decimals..&lt;br /&gt;&lt;br /&gt;eg:- 1.8F,21.3F etc&lt;br /&gt;&lt;br /&gt;Some data types are :-&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;Name&lt;/span&gt;. . . . .         &lt;span style=&quot;font-weight: bold;&quot;&gt;Description&lt;/span&gt;&lt;br /&gt;byte    . . . . .. . 8-bits &#39;&lt;br /&gt;sbyte   . . . .. . 8-bits&lt;br /&gt;int. . . . . . . ..     32-bit&lt;br /&gt;uint. . . . . . ..     32 bit&lt;br /&gt;short. . . . . ..16-bit&lt;br /&gt;ushort      . . . .. 16-bit &lt;br /&gt;long. . . . . . .. 64-bit &lt;br /&gt;ulong. . . . . ..     64-bit &lt;br /&gt;float    . . . . . .. 32-bit&lt;br /&gt;double. . . . .. 64-bit&lt;br /&gt;decimal  . . . . 96-bit &lt;br /&gt;bool    . . . . . . . true and false&lt;br /&gt;char. . . . . . . 16-bit</description><link>http://csharpasp.blogspot.com/2008/03/data-types-in-c.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-8385186588312213603</guid><pubDate>Tue, 04 Mar 2008 11:50:00 +0000</pubDate><atom:updated>2008-03-04T17:32:09.851+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Introduction</category><category domain="http://www.blogger.com/atom/ns#">Object Oriented Programming</category><category domain="http://www.blogger.com/atom/ns#">OOPS</category><title>First Program in C#</title><description>So, we are going to start with C#. C# is an Object Oriented Language developed by Microsoft Corporation for working with .NET platform. For working with C# you must have any version of Visual Studio installed on your Computer. For the latest case you will get Light Components like Microsoft C# Express Edition to Download from Microsoft which is absolutely free.&lt;br /&gt;Now we can see a simple program in C#.&lt;br /&gt;&lt;br /&gt;-------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;using System;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;namespace smilu&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;       class cHello&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            public static void Main(string[] args)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                Console.Write(&quot;Hello World&quot;);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        }        &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I know that if you are a fresher to C#; you may be wondering seeing the Code. There is nothing in much in the above code....&lt;br /&gt;&lt;br /&gt;Let&#39;s be now familiar with what is written in the above code.&lt;br /&gt;&lt;br /&gt;In the above code go from the begining...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The first line is&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;using System;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The using statement is used to add a &lt;span style=&quot;font-weight: bold;&quot;&gt;NAMESPACE &lt;/span&gt;into this program.&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 153, 0); font-weight: bold;&quot;&gt;&lt;span style=&quot;color: rgb(204, 102, 0);&quot;&gt;Namespaces&lt;/span&gt; &lt;/span&gt;are collection of &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;Classes&lt;/span&gt;. These Namespaces are used to avoid Class Name &lt;span style=&quot;font-weight: bold;&quot;&gt;Conflicts&lt;/span&gt;. ie, there may be situations where we must have two or more CLASSes with the same Name. So, inside a program, it will not allow to create two classes with the same name. So there exists a problem. So to avoid these types of conflicts we use Namespaces. So we create a namespace and add the classes inside the namespace and we create the other class with the same name in another namespace.&lt;br /&gt;&lt;br /&gt;In the above program we have added System namespace into this program. The System namespace contains CLASSes for implementing base datatypes.&lt;br /&gt;&lt;br /&gt;Now the second step&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;namespace smilu&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This step is used to create a User Defined namespace which contain classes. Here we have created a Namespace in the name of &quot;smilu&quot;.&lt;br /&gt;&lt;br /&gt;Then you must have noticed curly brackets throughout this program. These are the Bodies of Namespace, Classes and Functions.&lt;br /&gt;&lt;br /&gt;The Third step&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;class cHello&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As I have said in the earlier topics that C# is an Object Oriented Language. So an Object Oriented Language(OOL) must have a class. Without class we cannot say a program is purely Object Oriented(refer). So, in this step we are creating a CLASS with name &quot;cHello&quot;.&lt;br /&gt;We will be writing rest of the Codes inside the CLASS&lt;br /&gt;&lt;br /&gt;The Fourth Step&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;public static void Main(string[] args)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;font-size:130%;&quot; &gt;public static void Main()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is the most important Function of a Program. Without the &lt;span style=&quot;font-weight: bold;&quot;&gt;Main() &lt;/span&gt;function a program will not Execute. We write the &lt;span style=&quot;font-weight: bold;&quot;&gt;Main()&lt;/span&gt; function in C# like this. All the things written there are not necessary. We will check each keyword in the Declaration.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;public:&lt;/span&gt;&lt;br /&gt;public written in the function refers it Access to others.It is known as &quot;Access Specifier&quot; ie we have Given a public access to the Main function,so anywhere within the program we can access this function.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Static:&lt;/span&gt;&lt;br /&gt;C# is an OOL. So member variables and member functions can only be accessed through objects. Here in the case of Main it is the heart of a program. When we execute a program the first thing which gets executed is the Main() function. This is the first class so Object for this class can only be created inside the Main() function. So we must have to get the program started by executing the Main() function. That is why we declare a Static keyword to Main() function. So it is not necessary to create object for the class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;void:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;void means NOTHING.... void represents the return type of the Main() function. ie, what the main should return to the program. Here in this case we doesn&#39;t need anything to be returned.. so, we have given the return type as void.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Main(string[] args) :&lt;/span&gt;&lt;br /&gt;string[] args is used to store Command Line Arguments(if any). Command Line Arguments are arguments which we pass to a program while its execution with its Name.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Fifth Step&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Console.Write(&quot;Hello World&quot;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here we are creating Console application ie, we create a DOS based program. System.Console is a class which contains definitions for Write(), Read() etc... We mainly use&lt;br /&gt;Write(); For writing in the same line(output)&lt;br /&gt;WriteLine() This is used to Write in a string and set a break to the Line after that.&lt;br /&gt;Read() Read a single line&lt;br /&gt;ReadLine() Reading the strings.&lt;br /&gt;&lt;br /&gt;Here in the above code inside the write function I have written &quot;Hello World&quot;. The text inside the double quotes(&quot;&quot;) represenets the text to be printed as the output. What all we are write inside the &quot;&quot; of the Write() or WriteLine() functions will be printed as that itself exept some Escape charactors like...&lt;br /&gt;Commonly used escape charactors are...&lt;br /&gt;\n - For new Line&lt;br /&gt;\t - For a Tab Space&lt;br /&gt;\b - For a BackSpace etc...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NOTE:- C# is a case sensitive Language. So it is necessary that you write codes in appropriate cases itself as written above.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;After you type the program save the file with a Filename with extension &quot;.cs&quot;(eg:- Hello.cs).&lt;br /&gt;For executing the program take the Microsoft Visual Studio 2005 Command Prompt from&lt;br /&gt;&lt;br /&gt;START-&gt;PROGRAMS-&gt;MICROSOFT VISUAL STUDIO 2005-&gt;MICROSOFT VISUAL STUDIO TOOLS-&gt;MICROSOFT VISUAL STUDIO 2005 COMMAND PROMPT.&lt;br /&gt;&lt;br /&gt;&lt;object width=&quot;425&quot; height=&quot;355&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/4XgNxtO04uo&quot;&gt;&lt;/param&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/4XgNxtO04uo&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;355&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;Now navigate to the Folder you have saved the File.&lt;br /&gt;&lt;br /&gt;Compile the Code.&lt;br /&gt;&lt;br /&gt;For Comiling you have to do like this .. if the file name is Hello.cs&lt;br /&gt;&lt;br /&gt;In the COmmand prompt write &quot; csc Hello.cs &quot; and Press enter&lt;br /&gt;&lt;br /&gt;If the compilation returns Successfully write the File name and press Enter&lt;br /&gt;like&lt;br /&gt;&lt;br /&gt;&quot; Hello &quot; and Enter.&lt;br /&gt;&lt;br /&gt;You will get an output as&lt;br /&gt;&lt;br /&gt;Hello World</description><link>http://csharpasp.blogspot.com/2008/03/first-program-in-c.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-1476841076093416251</guid><pubDate>Sat, 01 Mar 2008 04:13:00 +0000</pubDate><atom:updated>2008-03-01T11:06:42.295+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.Net Framework</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Object Oriented Programming</category><category domain="http://www.blogger.com/atom/ns#">OOPS</category><title>What is Object Oriented Programming?</title><description>&lt;div align=&quot;left&quot;&gt;So, Lets start from the First. Before we all start one must be aware of what is Object Oriented Programming? So do you know what is Object Oriented Programming?&lt;/div&gt;&lt;div align=&quot;left&quot;&gt; &lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;/div&gt;&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;&lt;u&gt;Object Oriented Programming(OOP)&lt;/u&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;Object Oriented Programming was first introduced in 1960’s.The main reason behind this programming is to make the program user friendly. OOP concept is related to the real-world system (i.e concept of Classes and Objects). &lt;/p&gt;&lt;p&gt;&lt;br /&gt;What is a &lt;strong&gt;&lt;span style=&quot;font-size:130%;color:#ff6600;&quot;&gt;CLASS&lt;/span&gt;&lt;/strong&gt;?&lt;br /&gt;Class is just a Virtual concept of a collection of related items together which we cannot see or feel.In programming we create Classes to define collection of related variables and functions.&lt;br /&gt;Class is a user defined Data Type &lt;/p&gt;&lt;p&gt;&lt;br /&gt;What is an &lt;span style=&quot;color:#ff6600;&quot;&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Object?&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;In simple words -- Object is an Instance of a Class. We can access a Class only through its Objects.Without objects we cannot say a Class is existing.A thing which has the properties of a class is known as Objects.&lt;/p&gt;&lt;p&gt;For eg:-&lt;span style=&quot;font-size:85%;&quot;&gt; &lt;span style=&quot;color:#666666;&quot;&gt;Car is a Class and Tata Indica is an Object of the class Car&lt;br /&gt;Objects…. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#666666;&quot;&gt;&lt;p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;We generally identify object by its &lt;span style=&quot;color:#ff6600;&quot;&gt;State&lt;/span&gt;, &lt;span style=&quot;color:#ff6600;&quot;&gt;Behavior&lt;/span&gt; and &lt;span style=&quot;color:#ff6600;&quot;&gt;Identity&lt;/span&gt;.&lt;br /&gt;If we take a car Indica its state is its color, wheel, body, etc….&lt;/p&gt;&lt;p&gt;Its Behavior is moving, changing gears etc…&lt;br /&gt;And the identity of the car is its Number lets say KL-7 AD 2544. &lt;/p&gt;&lt;p&gt;Here state and behavior may be same for many objects but the identity of object will not be same for other object. &lt;/p&gt;&lt;p align=&quot;left&quot;&gt;&lt;br /&gt;Characteristics of OOProgramming…&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot;&gt;The main characteristics of Object Oriented Programming are:-&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Inheritance&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Encapsulation&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Abstraction&lt;/div&gt;&lt;/li&gt;&lt;li&gt;Polymorphism &lt;/li&gt;&lt;/ul&gt;&lt;p align=&quot;center&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;INHERITANCE&lt;/strong&gt;&lt;/p&gt;&lt;p align=&quot;left&quot;&gt;The ability of a class (Derived Class) to derive or Inherit the properties of another class (Base Class) is called Inheritance.Inheritance helps in the reusability of code hence making the program smaller and easy to use.&lt;br /&gt;Eg:- Parent child relationship. Child is Inherited from its parents &lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;br /&gt;&lt;strong&gt;ENCAPSULATION&lt;/strong&gt;&lt;/p&gt;&lt;p align=&quot;left&quot;&gt;&lt;br /&gt;Process of Hiding the data from a user is called Encapsulation; also called Data Hiding. &lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;br /&gt;&lt;strong&gt;ABSTRACTION&lt;/strong&gt;&lt;/p&gt;&lt;p align=&quot;left&quot;&gt;&lt;br /&gt;The process of showing essential features without giving any explanations is known as Abstraction. &lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;br /&gt;&lt;strong&gt;POLYMORPHISM&lt;/strong&gt;&lt;/p&gt;&lt;p align=&quot;left&quot;&gt;&lt;br /&gt;The name Poly Morphism means Many Forms. It is the process by which we create same things with different behaviors.&lt;br /&gt;Eg:- Function overloading…&lt;br /&gt;&lt;span style=&quot;color:#333333;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;em&gt;Eg Same person behaving in different ways. Make the person you teach as the example and ask him whether he behaves like the same when he is in front of his Principal and friend…. You can change the principal to Police also so the student will really understand what is poly morphism.&lt;/em&gt;&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;</description><link>http://csharpasp.blogspot.com/2008/03/object-oriented-programmingoop-object.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-8533097060282847594</guid><pubDate>Wed, 27 Feb 2008 03:22:00 +0000</pubDate><atom:updated>2008-02-27T09:19:23.776+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">.Net Framework</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Types of Application</title><description>&lt;span style=&quot;font-weight: bold;&quot;&gt;Before you start.........&lt;/span&gt;&lt;br /&gt;You should be aware what is a &lt;span style=&quot;font-weight: bold;&quot;&gt;program&lt;/span&gt;. What all are the key factors in a program...&lt;br /&gt;So first lets start with the Basics.....&lt;br /&gt;&lt;br /&gt;We all are creating Applications. So lets check what all are the functions performed by an Application.&lt;br /&gt;&lt;br /&gt;The functions performed by an application can be divided into three categories&lt;br /&gt;&lt;ul&gt;&lt;li&gt;User services&lt;/li&gt;&lt;li&gt;Business services  and&lt;/li&gt;&lt;li&gt;Data Services&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;         User Services layer constitutes the front end of the solution. It is also called the Presentation Layer because it provides the interactive user interface.&lt;br /&gt;&lt;br /&gt;    The business services layer controls the enforcement of business rules on the data of an organization.&lt;br /&gt;Business rules encompass those practices and activities that define the behavior of an organization.&lt;br /&gt;&lt;br /&gt;    The data services layer comprises of the data and the functions for manipulating this data.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;TYPES OF APPLICATIONS&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;    Applications may vary from Single-tier desktop applications to multi-tier applications (two, three or n-tier architecture).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;SINGLE-TIER&lt;/span&gt; Architecture&lt;br /&gt;&lt;br /&gt;    In a single-tier architecture a single executable file handles all functions relating to the user, business and data service layers. Such an Application is also called Monolithic applications.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;TWO-TIER&lt;/span&gt; Architecture&lt;br /&gt;&lt;br /&gt;    The tow-tier architecture divides an application into two components:-&lt;br /&gt;Client  -   Implements the user interface&lt;br /&gt;Server -   Stores Data&lt;br /&gt;    In case for this architecture the user and data services are located separately either on same machine or in separate machine.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;THREE-TIER&lt;/span&gt; Architecture&lt;br /&gt;&lt;br /&gt;    In case of Three-Tier architecture all the three service layers reside Separately, either on the same machine or on different machine. The user interface interacts with the Business logic. Business logic validates the data sent by the interfaces and forwards it to the database if it confirms to the requirement.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;n-TIER&lt;/span&gt; Architecture&lt;br /&gt;&lt;br /&gt;    An n-tier application uses business objects for handling business rules and data access. It has multiple servers handling business services. This application architecture provides various advantages over other types of application architectures. The advantages include extensibility, resilience to change, maintainability and scalability of the application.</description><link>http://csharpasp.blogspot.com/2008/02/types-of-application.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7133335550635087088.post-3805909569533600890</guid><pubDate>Tue, 26 Feb 2008 11:30:00 +0000</pubDate><atom:updated>2008-02-26T17:04:23.629+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Introduction</category><title>Welcome</title><description>This is the new Blog created by Smilu Varghese for the promotion of the young developers who are interested in Programming using the most famous .NET technologies..&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Regards&lt;br /&gt;SMilu</description><link>http://csharpasp.blogspot.com/2008/02/welcome.html</link><author>noreply@blogger.com (Smilu Varghese)</author><thr:total>0</thr:total></item></channel></rss>