<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-2936857470411742611</id><updated>2009-07-27T02:25:04.490-07:00</updated><title type='text'>Learn C# By Example</title><subtitle type='html'>This blog will take various topics of C# programming and provide easy examples for understanding the concepts.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://rtawate-csharp-book.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default'/><link rel='alternate' type='text/html' href='http://rtawate-csharp-book.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Raj Tawate</name><uri>http://www.blogger.com/profile/04439242338675919168</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2936857470411742611.post-5521162297995820072</id><published>2006-12-30T09:06:00.001-08:00</published><updated>2006-12-30T09:09:35.310-08:00</updated><title type='text'></title><content type='html'>&lt;P&gt;Looping Statements:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Overview :&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;for statement&lt;/STRONG&gt;&lt;/P&gt; &lt;P&gt;The for statement is used for iterating  over  a set of statements multiple times using an expression.  The expression is evaluated after each run of the iteration and stops when the expression evaluates to false.&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Let us see an example:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Type this code using your favourite editor:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 769px; HEIGHT: 336px" src="http://docs.google.com/File?id=dfbmjnsh_27gqmj7v"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Compile and run the program:&lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 669px; HEIGHT: 238px" src="http://docs.google.com/File?id=dfbmjnsh_28gwddb2"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;While Statement&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;IMG style="WIDTH: 799px; HEIGHT: 385px" src="http://docs.google.com/File?id=dfbmjnsh_29cnbsxn"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 669px; HEIGHT: 260px" src="http://docs.google.com/File?id=dfbmjnsh_30c65vf6"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;do staement&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;do while statement&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2936857470411742611-5521162297995820072?l=rtawate-csharp-book.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rtawate-csharp-book.blogspot.com/feeds/5521162297995820072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=2936857470411742611&amp;postID=5521162297995820072' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/5521162297995820072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/5521162297995820072'/><link rel='alternate' type='text/html' href='http://rtawate-csharp-book.blogspot.com/2006/12/looping-statements-overview-for.html' title=''/><author><name>Raj Tawate</name><uri>http://www.blogger.com/profile/04439242338675919168</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16240841743337695589'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2936857470411742611.post-7152221069302954090</id><published>2006-12-30T09:06:00.000-08:00</published><updated>2006-12-30T09:09:35.315-08:00</updated><title type='text'></title><content type='html'>&lt;P&gt;Conditional Statements and Looping&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; Most of the programming languages provide for conditional constructs, to enable the developer to provide for decision making in the program and respond to multiple scenarios.&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;The IF Statement:&lt;/STRONG&gt;&lt;/P&gt; &lt;P&gt; Assuming you are writing a program, which:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;1) Asks the user his age&lt;/P&gt; &lt;P&gt;2) If the age is &gt; 30 the program outputs "You are so old"&lt;/P&gt; &lt;P&gt;3) If the age is &lt; 30 the program outputs "You are so young"&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Type this program in your favourite text editor:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 680px; HEIGHT: 428px" src="http://docs.google.com/File?id=dfbmjnsh_19f48w59"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Compile the program using the csc compiler .  The syntax is : csc SampleIfStatement.cs&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;To Run the program, call the program with one paramter as the age:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 569px; HEIGHT: 190px" src="http://docs.google.com/File?id=dfbmjnsh_2042v8vg"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;The IF Statement with ELSE IF:&lt;/STRONG&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; There are situationns wherein you may want to handle more than 1 situations in your code.  Normally if there&lt;BR&gt;were too many possibilities , you would go for the &lt;STRONG&gt;SWITCH &lt;/STRONG&gt;statement which will take it later on.  But if there&lt;/P&gt; &lt;P&gt;are just 2/4 possibilities , you may use the IF statement with the ELSE IF flavour.&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Let us take an example to get a more clear idea for this construct:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Type this code in your favourite editor:&lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 761px; HEIGHT: 479px" src="http://docs.google.com/File?id=dfbmjnsh_22gxvhgm"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Compile and run the program:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 670px; HEIGHT: 285px" src="http://docs.google.com/File?id=dfbmjnsh_23ns3qn3"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;Switch Case Statement&lt;/STRONG&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; The Switch statement can be used to control the flow of the program by passing control to one of the case statements which evaluates to true in the scenario.&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; For example you want to write a program which does the following:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;1) Take the input of the user&lt;/P&gt; &lt;P&gt;2) If the user enters 1 : output "You selected Option 1: Add User"&lt;/P&gt; &lt;P&gt;3) If the user enters 2: output "You selected Option 2: Delete User"&lt;/P&gt; &lt;P&gt;4) If the user enters 3: output "You selected Option 3: Modif User"&lt;/P&gt; &lt;P&gt;5) If the user enters any other number : output "You selected to Exit"&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt; Edit the Program for Switch Case Statement:&lt;/STRONG&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 867px; HEIGHT: 592px" src="http://docs.google.com/File?id=dfbmjnsh_246gxkb"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Compile and run the program:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 670px; HEIGHT: 286px" src="http://docs.google.com/File?id=dfbmjnsh_25gwf4r3"&gt;&lt;/P&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2936857470411742611-7152221069302954090?l=rtawate-csharp-book.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rtawate-csharp-book.blogspot.com/feeds/7152221069302954090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=2936857470411742611&amp;postID=7152221069302954090' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/7152221069302954090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/7152221069302954090'/><link rel='alternate' type='text/html' href='http://rtawate-csharp-book.blogspot.com/2006/12/conditional-statements-and-looping-most.html' title=''/><author><name>Raj Tawate</name><uri>http://www.blogger.com/profile/04439242338675919168</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16240841743337695589'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2936857470411742611.post-1771111639152315499</id><published>2006-12-30T09:05:00.001-08:00</published><updated>2006-12-30T09:09:35.322-08:00</updated><title type='text'></title><content type='html'>&lt;P&gt;File Handling Using C# &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; The .NET Framework provides a extensive collection of base classes in the .NET Framework which make most of the work of file handling an efficient task, with the developer needed to write only the calls to these classes. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;To use the file handling classes efficiently , you may want to review the classes and their methods under the package System.IO.  We will cover some of the important classes, in our use-and-study methodology through the code samples itself. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Let us see in action how the file handling is done using .NET file handling classes: &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;Reading a Text File&lt;/STRONG&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; To read a text file , we will use the class StreamReader which provides an implementation of the Abstract class, TextReader and hence supports the following methods : &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;LI&gt;Read() -- Reads data from an input stream.  &lt;LI&gt;ReadLine() -- Reads a line of characters from the current stream and returns the data as a string.  &lt;P&gt;ReadToEnd() -- Reads all characters to the end of the TextReader and returns them as one string &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Let us write a class which reads a text file and outputs its contents to the system console. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Please type the following code using your favourite text editor: &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 687px; HEIGHT: 404px" src="http://docs.google.com/File?id=dfbmjnsh_11d22d2r"&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; Compile the program using the C# Compiler: &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 669px; HEIGHT: 185px" src="http://docs.google.com/File?id=dfbmjnsh_1283w5cp"&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Run the Program: &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Before you run the program , create a flat file with the name "samplefile.txt" and put any text in it and save &lt;/P&gt; &lt;P&gt;it in the same directory as the program. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Now you are ready to run the program, which will read this file and output the text to the system console: &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 669px; HEIGHT: 152px" src="http://docs.google.com/File?id=dfbmjnsh_13jk8th8"&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;Writing a Text File&lt;/STRONG&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; We will use the class StreamWriter to write to a file.  When we write to a file there are multiple possibilities, that the file may or may not exist, if the file is existing, we may have to specify whether the program should append to the existing file or overwrite the file. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;The StreamWriter has the following constructors : &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter%28System.String%29%20Constructor" target=contents&gt;StreamWriter(System.String) Constructor&lt;/A&gt;&lt;BR&gt;This constructor takes one paramter as String, which needs to be a valid filename. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter%28System.String%2C%20bool%29%20Constructor" target=contents&gt;StreamWriter(System.String, bool) Constructor&lt;/A&gt;&lt;BR&gt;This constructor takes an additional parameter which is bool, this paramter is the flag for overwriting the file if it exists. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;  &lt;P&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter%28System.IO.Stream%29%20Constructor" target=contents&gt;StreamWriter(System.IO.Stream) Constructor&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter%28System.IO.Stream%2C%20System.Text.Encoding%29%20Constructor" target=contents&gt;StreamWriter(System.IO.Stream, System.Text.Encoding) Constructor&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter%28System.IO.Stream%2C%20System.Text.Encoding%2C%20int%29%20Constructor" target=contents&gt;StreamWriter(System.IO.Stream, System.Text.Encoding, int) Constructor&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter%28System.String%2C%20bool%2C%20System.Text.Encoding%29%20Constructor" target=contents&gt;StreamWriter(System.String, bool, System.Text.Encoding) Constructor&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter%28System.String%2C%20bool%2C%20System.Text.Encoding%2C%20int%29%20Constructor" target=contents&gt;StreamWriter(System.String, bool, System.Text.Encoding, int) Constructor&lt;/A&gt;&lt;BR&gt; &lt;P&gt;StreamWriter Methods  &lt;P&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter.Write%28System.String%29%20Method" target=contents&gt;StreamWriter.Write(System.String) Method&lt;/A&gt; &lt;/P&gt; &lt;P&gt;This method takes a string to write to the file. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;StreamWriter.WriteLine(System.String) Method &lt;/P&gt; &lt;P&gt;This method is inherited from the TextWriter class,this method takes a string and writes to the file with a newline character. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter.Write%28char%5B%5D%2C%20int%2C%20int%29%20Method" target=contents&gt;StreamWriter.Write(char[], int, int) Method&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter.Write%28char%5B%5D%29%20Method" target=contents&gt;StreamWriter.Write(char[]) Method&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter.Write%28char%29%20Method" target=contents&gt;StreamWriter.Write(char) Method&lt;/A&gt; &lt;/P&gt; &lt;P&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter.Close%20Method" target=contents&gt;StreamWriter.Close Method&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter.Dispose%20Method" target=contents&gt;StreamWriter.Dispose Method&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter.Finalize%20Method" target=contents&gt;StreamWriter.Finalize Method&lt;/A&gt;&lt;BR&gt;&lt;A href="http://dotgnu.org/pnetlib-doc/System/IO/StreamWriter.html#StreamWriter.Flush%20Method" target=contents&gt;StreamWriter.Flush Method&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;Let us now create a program which creates a new text file and writes to it: &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Type in the following program using your favourite text editor: &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;  &lt;IMG style="WIDTH: 725px; HEIGHT: 323px" src="http://docs.google.com/File?id=dfbmjnsh_17d8bd23"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Compile the program: &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 597px; HEIGHT: 158px" src="http://docs.google.com/File?id=dfbmjnsh_15c4dfjz"&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Run the program to do a dir on the directory to see if a new file is created:&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;IMG style="WIDTH: 540px; HEIGHT: 287px" src="http://docs.google.com/File?id=dfbmjnsh_16fdj32j"&gt;&lt;/P&gt;&lt;/LI&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;As you will see a new file has been created and our text has been printed to that file.&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2936857470411742611-1771111639152315499?l=rtawate-csharp-book.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rtawate-csharp-book.blogspot.com/feeds/1771111639152315499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=2936857470411742611&amp;postID=1771111639152315499' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/1771111639152315499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/1771111639152315499'/><link rel='alternate' type='text/html' href='http://rtawate-csharp-book.blogspot.com/2006/12/file-handling-using-c.html' title=''/><author><name>Raj Tawate</name><uri>http://www.blogger.com/profile/04439242338675919168</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16240841743337695589'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2936857470411742611.post-2204882160142107715</id><published>2006-12-30T09:05:00.000-08:00</published><updated>2006-12-30T09:09:35.331-08:00</updated><title type='text'></title><content type='html'>&lt;P&gt;&lt;STRONG&gt;Executable C# Class:&lt;/STRONG&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Every C# class, which needs to be run as an executable needs to have the following method: &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;public static void Main() &lt;/P&gt; &lt;P&gt;{ &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;} &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;or &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;public static void Main(String[] args) &lt;/P&gt; &lt;P&gt;{ &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;} &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;When you run the compiled exe, the code in the &lt;Main&gt; method is called first. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;Since we wanted to create an exe, our code also contains this code, which is &lt;/P&gt; &lt;P&gt;called when the exe is executed.&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;The next line we need to understand is :&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;FONT face="Courier New"&gt;Console.WriteLine("Hello World! How are you");&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;The WriteLine method in the System.Console class, lets you specify a string, which&lt;/P&gt; &lt;P&gt;is printed on the system console.&lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;The Console class is part of the System package in the Core .NET classes.   &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;Classes:&lt;/STRONG&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;The class is a foundation of an Object orieneted programming paradigm.  You can use a class to encapsulate the complexity of physical implmentation from other programming units.  Anybody can get the benefits of this implementation as long as they know the constructors, the destructors and the methods. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;The Constructor:&lt;/STRONG&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;A constructor is a method with the same name as the class.  A blank constructor is automatically called when the object of the class is created.  One of the key difference between a normal method and a constructor is that , the constructor does not return any value. &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;&lt;STRONG&gt;Methods :&lt;/STRONG&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;A method is a wrapper for a sectional piece of  code in a class, which does implments a part of the functionality of the class itself.  For example, if you have a class called Calculator, there may be methods like addNumber(), substractNumber() &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;    Method Parameter: &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;    Methods can be defined with parameters, every parameter is defined with its datatype.  For example addNumber   (int    firstNumber, int secondNumber) &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt;    Method return values: &lt;/P&gt; &lt;P&gt;     &lt;/P&gt; &lt;P&gt;    Methods are required to define a return data type, or if it is intended to not return type, then the method should be defined as returning void.   For example : public void resetNumbers() &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt; &lt;P&gt; &lt;/P&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2936857470411742611-2204882160142107715?l=rtawate-csharp-book.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rtawate-csharp-book.blogspot.com/feeds/2204882160142107715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=2936857470411742611&amp;postID=2204882160142107715' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/2204882160142107715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/2204882160142107715'/><link rel='alternate' type='text/html' href='http://rtawate-csharp-book.blogspot.com/2006/12/executable-c-class-every-c-class-which.html' title=''/><author><name>Raj Tawate</name><uri>http://www.blogger.com/profile/04439242338675919168</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16240841743337695589'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2936857470411742611.post-206025915034307361</id><published>2006-12-30T09:04:00.000-08:00</published><updated>2006-12-30T09:09:35.338-08:00</updated><title type='text'></title><content type='html'>&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;As with any other programming languages, let us start with a simple program called a "hello world".  This program will just display a line "Hello World" , but in the process, we plan to learn:&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;1) How to write a basic C# progam&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;2) Sections of a c# program&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;2) How to compile a basic c# program&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt; System;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;/FONT&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;public class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt; HelloWorld&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt;{&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN&gt;    &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;static&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt; Main(&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;string&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt;[] args)&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;   &lt;/SPAN&gt;&lt;SPAN&gt;      &lt;/SPAN&gt;{&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;        &lt;/SPAN&gt;&lt;SPAN&gt;      &lt;/SPAN&gt;Console.WriteLine("Hello World! How are you");&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;   &lt;/SPAN&gt;&lt;SPAN&gt;      &lt;/SPAN&gt;}&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;FONT style="BACKGROUND-COLOR: #cccccc"&gt;} &lt;/FONT&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;STRONG&gt;Typing /Editing your first program:&lt;/STRONG&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt; Open your favourite text editor, which can be "notepad" or "editplus" or any other text editor&lt;/P&gt; &lt;P class=MsoNormal&gt;you prefer and type out the above program.&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;Save the program as "HelloWorld.cs"&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;STRONG&gt;Compiling your first program:&lt;/STRONG&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;Open the visual studio command prompt&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;IMG style="WIDTH: 849px; HEIGHT: 170px" src="http://docs.google.com/File?id=dfbmjnsh_4gtf67z"&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;Type the C# Compiler by calling : csc&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;Pass the C# Compiler the name of your program : in this case HelloWorld.cs&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;IMG style="WIDTH: 549px; HEIGHT: 157px" src="http://docs.google.com/File?id=dfbmjnsh_5dpb3dd"&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;Press enter.&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;If you have not made any syntax errors, the program will compile and you should see&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;the following in the command window&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;IMG style="WIDTH: 550px; HEIGHT: 171px" src="http://docs.google.com/File?id=dfbmjnsh_6f7dkxw"&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;Your first program will be compiled into an exe file, run a dir command if there is an exe file in the directory:&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;IMG style="WIDTH: 555px; HEIGHT: 203px" src="http://docs.google.com/File?id=dfbmjnsh_7fz4r7j"&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;As you see, the directory contains an exe file : HelloWorld.exe&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;Run the exe file by typing : HelloWorld.exe and press enter&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;IMG style="WIDTH: 556px; HEIGHT: 203px" src="http://docs.google.com/File?id=dfbmjnsh_8htc93h"&gt;&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt;There you are !!!.  Your first C# program has run successfully and you see the output "Hello World" in the console.&lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt; &lt;P class=MsoNormal&gt; &lt;/P&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2936857470411742611-206025915034307361?l=rtawate-csharp-book.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rtawate-csharp-book.blogspot.com/feeds/206025915034307361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=2936857470411742611&amp;postID=206025915034307361' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/206025915034307361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2936857470411742611/posts/default/206025915034307361'/><link rel='alternate' type='text/html' href='http://rtawate-csharp-book.blogspot.com/2006/12/as-with-any-other-programming-languages.html' title=''/><author><name>Raj Tawate</name><uri>http://www.blogger.com/profile/04439242338675919168</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='16240841743337695589'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry></feed>