<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-163936697130312525</id><updated>2011-11-27T15:55:34.828-08:00</updated><category term='asp.net'/><category term='.net 2.0'/><category term='c++'/><category term='vb.net'/><category term='data reapeter'/><category term='c'/><title type='text'>Srihari Atthuluri</title><subtitle type='html'>This blog contains the programming tips 'n' examples</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-6167738724568550279</id><published>2008-10-10T00:00:00.001-07:00</published><updated>2008-10-10T00:00:17.839-07:00</updated><title type='text'>3.1. Types</title><content type='html'>3.1. Types&lt;br /&gt;C# is a strongly typed language. In a strongly typed language you must declare the type of each object you create (e.g., integers, floats, strings, windows, buttons, etc.), and the compiler will help you prevent bugs by enforcing that only data of the right type is assigned to those objects. The type of an object signals to the compiler the size of that object (e.g., int indicates an object of 4 bytes) and its capabilities (e.g., buttons can be drawn, pressed, and so forth).&lt;br /&gt;&lt;br /&gt; C# 1.1 programmers take note: until Version 2, .NET was strongly typed in everything except collections. With the addition of generics, however, it is now easy to create strongly typed collection classes, as shown in Chapter 9.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Like C++ and Java, C# divides types into two sets: intrinsic (built-in) types that the language offers and user-defined types that the programmer defines.&lt;br /&gt;&lt;br /&gt;C# also divides the set of types into two other categories: value types and reference types.[1] The principal difference between value and reference types is the manner in which their values are stored in memory. A value type holds its actual value in memory allocated on the stack (or it is allocated as part of a larger reference type object). The address of a reference type variable sits on the stack, but the actual object is stored on the heap.&lt;br /&gt;&lt;br /&gt;[1] All the intrinsic types are value types except for Object (discussed in Chapter 5) and String (discussed in Chapter 10). All user-defined types are reference types except for structs (discussed in Chapter 7) and enumerated types (discussed in Chapter 3).&lt;br /&gt;&lt;br /&gt; C and C++ programmers take note: in C#, there is no explicit indication that an object is a reference type (i.e., no use of the &amp; operator). Also, pointers aren't normally used (but see Chapter 22 for the exception to this rule).&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you have a very large object, putting it on the heap has many advantages. Chapter 4 discusses the various advantages and disadvantages of working with reference types; the current chapter focuses on the intrinsic value types available in C#.&lt;br /&gt;&lt;br /&gt; In C#, the size and format of the storage for different intrinsic types (e.g., int) are platform-independent and consistent across all .NET languages.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;C# also supports C++ style pointer types, but these are used only when working with unmanaged code. Unmanaged code is created outside of the .NET platform (for example, COM objects; working with COM objects is discussed in Chapter 22).&lt;br /&gt;&lt;br /&gt;3.1.1. Working with Built-in Types&lt;br /&gt;The C# language offers the usual cornucopia of intrinsic (built-in) types one expects in a modern language, each of which maps to an underlying type supported by the .NET CLS. Mapping the C# primitive types to the underlying .NET type ensures that objects created in C# can be used interchangeably with objects created in any other language compliant with the .NET CLS, such as VB.NET.&lt;br /&gt;&lt;br /&gt; Java programmers take note: C# has a broader range of basic types than Java. The C# decimal type is notable, and is useful for financial calculations.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Each type has a specific and unchanging size. Unlike with C++, a C# int is always 4 bytes because it maps to an Int32 in the .NET CLS. Table 3-1 lists the built-in value types offered by C#. &lt;br /&gt;&lt;br /&gt;Table 3-1. C# built-in value types Type&lt;br /&gt; Size (in bytes)&lt;br /&gt; .NET type&lt;br /&gt; Description&lt;br /&gt; &lt;br /&gt;byte&lt;br /&gt;&lt;br /&gt; 1&lt;br /&gt;&lt;br /&gt; Byte&lt;br /&gt;&lt;br /&gt; Unsigned (values 0-255).&lt;br /&gt; &lt;br /&gt;char&lt;br /&gt;&lt;br /&gt; 2&lt;br /&gt;&lt;br /&gt; Char&lt;br /&gt;&lt;br /&gt; Unicode characters.&lt;br /&gt; &lt;br /&gt;bool&lt;br /&gt;&lt;br /&gt; 1&lt;br /&gt;&lt;br /&gt; Boolean&lt;br /&gt;&lt;br /&gt; True or false.&lt;br /&gt; &lt;br /&gt;sbyte&lt;br /&gt;&lt;br /&gt; 1&lt;br /&gt;&lt;br /&gt; SByte&lt;br /&gt;&lt;br /&gt; Signed (values -128 to 127).&lt;br /&gt; &lt;br /&gt;short&lt;br /&gt;&lt;br /&gt; 2&lt;br /&gt;&lt;br /&gt; Int16&lt;br /&gt;&lt;br /&gt; Signed (short) (values -32,768 to 32,767).&lt;br /&gt; &lt;br /&gt;ushort&lt;br /&gt;&lt;br /&gt; 2&lt;br /&gt;&lt;br /&gt; UInt16&lt;br /&gt;&lt;br /&gt; Unsigned (short) (values 0 to 65,535).&lt;br /&gt; &lt;br /&gt;int&lt;br /&gt;&lt;br /&gt; 4&lt;br /&gt;&lt;br /&gt; Int32&lt;br /&gt;&lt;br /&gt; Signed integer values between -2,147,483,648 and 2,147,483,647.&lt;br /&gt; &lt;br /&gt;uint&lt;br /&gt;&lt;br /&gt; 4&lt;br /&gt;&lt;br /&gt; UInt32&lt;br /&gt;&lt;br /&gt; Unsigned integer values between 0 and 4,294,967,295.&lt;br /&gt; &lt;br /&gt;float&lt;br /&gt;&lt;br /&gt; 4&lt;br /&gt;&lt;br /&gt; Single&lt;br /&gt;&lt;br /&gt; Floating-point number. Holds the values from approximately +/-1.5 * 10-45 to approximately +/-3.4 * 1038 with seven significant figures.&lt;br /&gt; &lt;br /&gt;double&lt;br /&gt;&lt;br /&gt; 8&lt;br /&gt;&lt;br /&gt; Double&lt;br /&gt;&lt;br /&gt; Double-precision floating point. Holds the values from approximately +/-5.0 * 10-324 to approximately +/-1.8 * 10308 with 15-16 significant figures.&lt;br /&gt; &lt;br /&gt;decimal&lt;br /&gt;&lt;br /&gt; 16&lt;br /&gt;&lt;br /&gt; Decimal&lt;br /&gt;&lt;br /&gt; Fixed-precision up to 28 digits and the position of the decimal point. This is typically used in financial calculations. Requires the suffix "m" or "M."&lt;br /&gt; &lt;br /&gt;long&lt;br /&gt;&lt;br /&gt; 8&lt;br /&gt;&lt;br /&gt; Int64&lt;br /&gt;&lt;br /&gt; Signed integers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.&lt;br /&gt; &lt;br /&gt;ulong&lt;br /&gt;&lt;br /&gt; 8&lt;br /&gt;&lt;br /&gt; UInt64&lt;br /&gt;&lt;br /&gt; Unsigned integers ranging from 0 to 0xffffffffffffffff.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; C and C++ programmers take note: in C#, Boolean variables can only have the values TRue or false. Integer values don't equate to Boolean values in C# and there is no implicit conversion.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In addition to these primitive types, C# has two other value types: enum (considered later in this chapter) and struct (see Chapter 4). Chapter 4 also discusses other subtleties of value types, such as forcing value types to act as reference types through a process known as boxing, and that value types don't "inherit."&lt;br /&gt;&lt;br /&gt;The Stack and the Heap&lt;br /&gt;A stack is a data structure used to store items on a last-in first-out basis (like a stack of dishes at the buffet line in a restaurant). The stack refers to an area of memory supported by the processor, on which the local variables are stored.&lt;br /&gt;&lt;br /&gt;In C#, value types (e.g., integers) are allocated on the stackan area of memory is set aside for their valueand this area is referred to by the name of the variable.&lt;br /&gt;&lt;br /&gt;Reference types (e.g., objects) are allocated on the heap. The heap is an area of memory used to allocate space for objects.When an object is allocated on the heap, its address is returned, and that address is assigned to a reference.&lt;br /&gt;&lt;br /&gt;Objects on the stack are destroyed when they go out of scope. Typically a stack frame is defined by a function. Thus, if you declare a local variable within a function (as explained later in this chapter), the objects you place on the stack within that function will be destroyed when the function ends.&lt;br /&gt;&lt;br /&gt;Objects on the heap are garbage-collected sometime after the final reference to them is destroyed.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; C and C++ programmers take note: C# manages all memory with a garbage collection systemthere is no delete operator.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3.1.1.1 Choosing a built-in type&lt;br /&gt;Typically you decide which size integer to use (short , int, or long) based on the magnitude of the value you want to store. For example, a ushort can only hold values from 0 through 65,535, while a uint can hold values from 0 through 4,294,967,295.&lt;br /&gt;&lt;br /&gt;That said, memory is fairly cheap, and programmer time is increasingly expensive; most of the time you'll simply declare your variables to be of type int, unless there is a good reason to do otherwise.&lt;br /&gt;&lt;br /&gt; Integers are often faster than smaller types because modern CPUs are optimized for dealing with them. Further, because of padding inserted for alignment, there's often no space gain to be had from smaller datatypes.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Float , double, and decimal offer varying degrees of size and precision. For most small fractional numbers, float is fine. Note that the compiler assumes that any number with a decimal point is a double unless you tell it otherwise. To assign a literal float, follow the number with the letter f (assigning values to literals is discussed in detail later in this chapter):&lt;br /&gt;&lt;br /&gt;float someFloat = 57f;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The char type represents a Unicode character. char literals can be simple, Unicode, or escape characters enclosed by single quote marks. For example, A is a simple character while \u0041 is a Unicode character. Escape characters are special two-character tokens in which the first character is a backslash. For example, \t is a horizontal tab. The common escape characters are shown in Table 3-2.&lt;br /&gt;&lt;br /&gt;Table 3-2. Common escape characters Char&lt;br /&gt; Meaning&lt;br /&gt; &lt;br /&gt;\'&lt;br /&gt;&lt;br /&gt; Single quote&lt;br /&gt; &lt;br /&gt;\"&lt;br /&gt;&lt;br /&gt; Double quote&lt;br /&gt; &lt;br /&gt;\\&lt;br /&gt;&lt;br /&gt; Backslash&lt;br /&gt; &lt;br /&gt;\0&lt;br /&gt;&lt;br /&gt; Null&lt;br /&gt; &lt;br /&gt;\a&lt;br /&gt;&lt;br /&gt; Alert&lt;br /&gt; &lt;br /&gt;\b&lt;br /&gt;&lt;br /&gt; Backspace&lt;br /&gt; &lt;br /&gt;\f&lt;br /&gt;&lt;br /&gt; Form feed&lt;br /&gt; &lt;br /&gt;\n&lt;br /&gt;&lt;br /&gt; Newline&lt;br /&gt; &lt;br /&gt;\r&lt;br /&gt;&lt;br /&gt; Carriage return&lt;br /&gt; &lt;br /&gt;\t&lt;br /&gt;&lt;br /&gt; Horizontal tab&lt;br /&gt; &lt;br /&gt;\v&lt;br /&gt;&lt;br /&gt; Vertical tab&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3.1.1.2 Converting built-in types&lt;br /&gt;Objects of one type can be converted into objects of another type either implicitly or explicitly. Implicit conversions happen automatically; the compiler takes care of it for you. Explicit conversions happen when you "cast" a value to a different type. The semantics of an explicit conversion are "Hey! Compiler! I know what I'm doing." This is sometimes called "hitting it with the big hammer" and can be very useful or very painful, depending on whether your thumb is in the way of the nail.&lt;br /&gt;&lt;br /&gt; VB6 programmers take note: in VB6 you can easily mix strings and the character datatype; a character is treated as a string with a length of 1. But C# is type-safe. To assign a literal character to a char variable, you must surround it with single quotes.&lt;br /&gt;&lt;br /&gt;Note also that the VB6 functions to convert between a character and its ASCII equivalent (Chr( ) and Asc()) don't exist in C#. To convert a char to its ASCII equivalent, cast it as an int (integer):&lt;br /&gt;&lt;br /&gt;(int)'A'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To convert a number to a char, cast the number as a char:&lt;br /&gt;&lt;br /&gt;(char)65&lt;br /&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Implicit conversions happen automatically and are guaranteed not to lose information. For example, you can implicitly cast from a short int (2 bytes) to an int (4 bytes). No matter what value is in the short, it is not lost when converting to an int:&lt;br /&gt;&lt;br /&gt;short x = 5;&lt;br /&gt;int y = x; // implicit conversion&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you convert the other way, however, you certainly can lose information. If the value in the int is greater than 32,767, it will be truncated in the conversion. The compiler will not perform an implicit conversion from int to short:&lt;br /&gt;&lt;br /&gt;short x;&lt;br /&gt;int y = 500;&lt;br /&gt;x = y;  // won't compile&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You must explicitly convert using the cast operator:&lt;br /&gt;&lt;br /&gt;short x;&lt;br /&gt;int y = 500;&lt;br /&gt;x = (short) y;  // OK&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;All the intrinsic types define their own conversion rules. At times it is convenient to define conversion rules for your user-defined types, as discussed in Chapter 5.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-6167738724568550279?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/6167738724568550279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=6167738724568550279' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6167738724568550279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6167738724568550279'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/10/31-types.html' title='3.1. Types'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-3359380009084249726</id><published>2008-10-09T23:59:00.001-07:00</published><updated>2008-10-09T23:59:46.999-07:00</updated><title type='text'>C# Language Fundamentals</title><content type='html'>Chapter 2 demonstrated a very simple C# program. Nonetheless, that little program was complex enough that I had to skip some of the pertinent details. This chapter illuminates these details by delving more deeply into the syntax and structure of the C# language itself.&lt;br /&gt;&lt;br /&gt;This chapter discusses the type system in C#, drawing a distinction between built-in types (int, bool, etc.) versus user-defined types (types you create as classes and interfaces). The chapter also covers programming fundamentals such as how to create and use variables and constants. It then goes on to introduce enumerations, strings, identifiers, expressions, and statements.&lt;br /&gt;&lt;br /&gt;The second part of the chapter explains and demonstrates the use of flow control statements, using the if, switch, while, do...while, for, and foreach statements. Also discussed are operators, including the assignment, logical, relational, and mathematical operators. This is followed by an introduction to namespaces and a short tutorial on the C# precompiler.&lt;br /&gt;&lt;br /&gt;Although C# is principally concerned with the creation and manipulation of objects, it is best to start with the fundamental building blocks: the elements from which objects are created. These include the built-in types that are an intrinsic part of the C# language as well as the syntactic elements of C#.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-3359380009084249726?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/3359380009084249726/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=3359380009084249726' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/3359380009084249726'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/3359380009084249726'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/10/c-language-fundamentals.html' title='C# Language Fundamentals'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-6996612339800526556</id><published>2008-10-09T23:57:00.001-07:00</published><updated>2008-10-09T23:58:57.369-07:00</updated><title type='text'>2. Getting Started: "Hello World"</title><content type='html'>It is a time-honored tradition to start a programming book with a "Hello World" program. In this chapter, we create, compile, and run a simple "Hello World" program written in C#. The analysis of this brief program will introduce key features of the C# language.&lt;br /&gt;&lt;br /&gt;Example 2-1 illustrates the fundamental elements of a very elementary C# program.&lt;br /&gt;&lt;br /&gt;Example 2-1. A simple "Hello World" program in C#&lt;br /&gt;class Hello&lt;br /&gt;{&lt;br /&gt;    static void Main( )&lt;br /&gt;    {&lt;br /&gt;        // Use the system console object&lt;br /&gt;        System.Console.WriteLine("Hello World");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Compiling and running this code displays the words "Hello World" at the console. Before we compile and run it, let's first take a closer look at this simple program.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;2.1. Classes, Objects, and Types&lt;/span&gt;&lt;br /&gt;The essence of object-oriented programming is the creation of new types. A type represents a thing. Sometimes the thing is abstract, such as a data table or a thread; sometimes it is more tangible, such as a button in a window. A type defines the thing's general properties and behaviors.&lt;br /&gt;&lt;br /&gt;If your program uses three instances of a button type in a windowsay, an OK, a Cancel, and a Help buttoneach button will have a size, though the specific size of each button may differ. Similarly, all the buttons will have the same behaviors (draw, click), though how they actually implement these behaviors may vary. Thus, the details might differ among the individual buttons, but they are all of the same type.&lt;br /&gt;&lt;br /&gt;As in many object-oriented programming languages, in C# a type is defined by a class, while the individual instances of that class are known as objects. Later chapters explain that there are other types in C# besides classes, including enums, structs, and delegates, but for now the focus is on classes.&lt;br /&gt;&lt;br /&gt;The "Hello World" program declares a single type: the Hello class. To define a C# type, you declare it as a class using the class keyword, give it a namein this case, Helloand then define its properties and behaviors. The property and behavior definitions of a C# class must be enclosed by open and closed braces ({}).&lt;br /&gt;&lt;br /&gt; C++ programmers take note: there is no semicolon after the closing brace.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;2.1.1. Methods&lt;/span&gt;&lt;br /&gt;A class has both properties and behaviors. Behaviors are defined with member methods; properties are discussed in Chapter 3.&lt;br /&gt;&lt;br /&gt;A method is a function owned by your class. In fact, member methods are sometimes called member functions. The member methods define what your class can do or how it behaves. Typically, methods are given action names, such as WriteLine( ) or AddNumbers( ). In the case shown here, however, the class method has a special name, Main( ), which doesn't describe an action but does designate to the CLR that this is the main, or first method, for your class.&lt;br /&gt;&lt;br /&gt; C++ programmers take note: Main( ) is capitalized in C# and must be a member of a class, not a global member. Main( ) can also return int or void.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The CLR calls Main() when your program starts. Main() is the entry point for your program, and every C# program must have a Main( ) method.[1]&lt;br /&gt;&lt;br /&gt;[1] It's technically possible to have multiple Main( ) methods in C#; in that case you use the /main command-line switch to tell C# which class contains the Main( ) method that should serve as the entry point to the program.&lt;br /&gt;&lt;br /&gt;Method declarations are a contract between the creator of the method and the consumer (user) of the method. It is likely that the creator and consumer of the method will be the same programmer, but this doesn't have to be so: it is possible that one member of a development team will create the method and another programmer will use it.&lt;br /&gt;&lt;br /&gt; Java programmers take note: Main( ) is the entry point for every C# program, similar in some ways to the Java applet run( ) method or the Java program's main() method.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To declare a method, you specify a return value type followed by a name. Method declarations also require parentheses, whether the method accepts parameters or not. For example:&lt;br /&gt;&lt;br /&gt;int myMethod(int size)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;declares a method named myMethod() that takes one parameter: an integer that will be referred to within the method as size. This method returns an integer value. The return value type tells the consumer of the method what kind of data the method will return when it finishes running.&lt;br /&gt;&lt;br /&gt;Some methods don't return a value at all; these are said to return void, which is specified by the void keyword. For example:&lt;br /&gt;&lt;br /&gt;void myVoidMethod();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;declares a method that returns void and takes no parameters. In C# you must always declare a return type or void.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;2.1.2. Comments&lt;/span&gt;&lt;br /&gt;A C# program can also contain comments. Take a look at the first line after the opening brace of the main method shown earlier:&lt;br /&gt;&lt;br /&gt;// Use the system console object&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The text begins with two forward slash marks (//). These designate a comment. A comment is a note to the programmer and doesn't affect how the program runs. C# supports three types of comments.&lt;br /&gt;&lt;br /&gt;The first type, just shown, indicates that all text to the right of the comment mark is to be considered a comment, until the end of that line. This is known as a C++ style comment.&lt;br /&gt;&lt;br /&gt;The second type of comment, known as a C-style comment, begins with an open comment mark (/*) and ends with a closed comment mark (*/). This allows comments to span more than one line without having to have // characters at the beginning of each comment line, as shown in Example 2-2.&lt;br /&gt;&lt;br /&gt;Example 2-2. Illustrating multiline comments&lt;br /&gt;namespace HelloWorld&lt;br /&gt;{&lt;br /&gt;    class HelloWorld&lt;br /&gt;    {&lt;br /&gt;        static void Main( )&lt;br /&gt;        {&lt;br /&gt;            /* Use the system console object&lt;br /&gt;               as explained in the text */&lt;br /&gt;            System.Console.WriteLine("Hello World");&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;While you can't nest C++ style comments, it is possible to nest C++ style comments within C-style comments. For this reason, it is common to use C++ style comments whenever possible, and to reserve the C-style comments for "commenting-out" blocks of code.&lt;br /&gt;&lt;br /&gt;The third and final type of comment that C# supports is used to associate external XML-based documentation with your code, and is illustrated in Chapter 13.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;2.1.3. Console Applications&lt;/span&gt;&lt;br /&gt;"Hello World" is an example of a console program. A console application typically has no graphical user interface (GUI); there are no list boxes, buttons, windows, and so forth. Text input and output are handled through the standard console (typically a command or DOS window on your PC). Sticking to console applications for now helps simplify the early examples in this book, and keeps the focus on the language itself. In later chapters, we'll turn our attention to Windows and web applications, and at that time we'll focus on the Visual Studio .NET GUI design tools.&lt;br /&gt;&lt;br /&gt;All that the Main() method does in this simple example is write the text "Hello World" to the standard output (typically a command prompt window). Standard output is managed by an object named Console. This Console object has a method called WriteLine( ) that takes a string (a set of characters) and writes it to the standard output. When you run this program, a command or DOS screen will pop up on your computer monitor and display the words "Hello World."&lt;br /&gt;&lt;br /&gt;You invoke a method with the dot operator (.). Thus, to call the Console object's WriteLine() method, you write Console.WriteLine(...), filling in the string to be printed.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;2.1.4. Namespaces&lt;/span&gt;&lt;br /&gt;Console is only one of a tremendous number of useful types that are part of the .NET FCL. Each class has a name, and thus the FCL contains thousands of names, such as ArrayList, Hashtable, FileDialog, DataException, EventArgs, and so on. There are hundreds, thousands, even tens of thousands of names.&lt;br /&gt;&lt;br /&gt;This presents a problem. No developer can possibly memorize all the names that the .NET Framework uses, and sooner or later you are likely to create an object and give it a name that has already been used. What will happen if you purchase a Hashtable class from another vendor, only to discover that it conflicts with the Hashtable class that .NET provides? Remember, each class in C# must have a unique name and you typically can't rename classes in a vendor's code!&lt;br /&gt;&lt;br /&gt;The solution to this problem is the use of namespaces. A namespace restricts a name's scope, making it meaningful only within the defined namespace.&lt;br /&gt;&lt;br /&gt; C++ programmers take note: C++ namespaces are delimited with the scope resolution operator (::), in C# you use the dot (.) operator.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Java programmers take note: namespaces provide many of the benefits of packages.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Assume that I tell you that Jim is an engineer. The word "engineer" is used for many things in English, and can cause confusion. Does he design buildings? Write software? Run a train?&lt;br /&gt;&lt;br /&gt;In English I might clarify by saying "he's a scientist," or "he's a train engineer." A C# programmer could tell you that Jim is a science.engineer rather than a TRain.engineer. The namespace (in this case, science or train) restricts the scope of the word that follows. It creates a "space" in which that name is meaningful.&lt;br /&gt;&lt;br /&gt;Further, it might happen that Jim is not just any kind of science.engineer. Perhaps Jim graduated from MIT with a degree in software engineering, not civil engineering (are civil engineers especially polite?). Thus, the object that is Jim might be defined more specifically as a science.software.engineer. This classification implies that the namespace software is meaningful within the namespace science, and that engineer in this context is meaningful within the namespace software. If later you learn that Charlotte is a transportation.train.engineer, you will not be confused as to what kind of engineer she is. The two uses of engineer can coexist, each within its own namespace.&lt;br /&gt;&lt;br /&gt;Similarly, if it turns out that .NET has a Hashtable class within its System.Collections namespace, and that I have also created a Hashtable class within a ProgCSharp.DataStructures namespace, there is no conflict because each exists in its own namespace.&lt;br /&gt;&lt;br /&gt;In Example 2-1, the Console class' name is identified as being in the System namespace by using the code:&lt;br /&gt;&lt;br /&gt;System.Console.WriteLine();&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;2.1.5. The Dot Operator (.)&lt;/span&gt;&lt;br /&gt;In Example 2-1, the dot operator (.) is used both to access a method (and data) in a class (in this case, the method WriteLine( )), and to restrict the class name to a specific namespace (in this case, to locate Console within the System namespace). This works well because in both cases we are "drilling down" to find the exact thing we want. The top level is the System namespace (which contains all the System objects that the FCL provides); the Console type exists within that namespace, and the WriteLine() method is a member function of the Console type.&lt;br /&gt;&lt;br /&gt;In many cases, namespaces are divided into subspaces. For example, the System namespace contains a number of subnamespaces such as Data, Configuration, Collections, and so forth, while the Collections namespace itself is divided into multiple subnamespaces.&lt;br /&gt;&lt;br /&gt;Namespaces can help you organize and compartmentalize your types. When you write a complex C# program, you might want to create your own namespace hierarchy, and there is no limit to how deep this hierarchy can be. The goal of namespaces is to help you divide and conquer the complexity of your object hierarchy.&lt;br /&gt;&lt;br /&gt;2.1.6. The using Keyword&lt;br /&gt;Rather than writing the word System before Console, you could specify that you will be using types from the System namespace by writing the directive:&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;at the top of the listing, as shown in Example 2-3.&lt;br /&gt;&lt;br /&gt;Example 2-3. The using keyword&lt;br /&gt;using System;&lt;br /&gt;class Hello&lt;br /&gt;{&lt;br /&gt;    static void Main( )&lt;br /&gt;    {&lt;br /&gt;        //Console from the System namespace&lt;br /&gt;        Console.WriteLine("Hello World");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Notice the using System directive is placed before the Hello class definition. Visual Studio .NET 2005 defaults to including three using statements in every console application (System, System.Collections.Generic, System.Text).&lt;br /&gt;&lt;br /&gt;Although you can designate that you are using the System namespace, you can't designate that you are using the System.Console object, as you can with some languages. Example 2-4 won't compile.&lt;br /&gt;&lt;br /&gt;Example 2-4. Code that doesn't compile (not legal C#)&lt;br /&gt;using System.Console;&lt;br /&gt;class Hello&lt;br /&gt;{&lt;br /&gt;    static void Main( )&lt;br /&gt;    {&lt;br /&gt;        //Console from the System namespace&lt;br /&gt;        WriteLine("Hello World");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This generates the compile error:&lt;br /&gt;&lt;br /&gt;error CS0138: A using namespace directive can only be applied&lt;br /&gt;to namespaces; 'System.Console' is a type not a namespace&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; If you are using Visual Studio, you will know that you've made a mistake, because when you type usingSystem followed by the dot, Visual Studio .NET 2005 will provide a list of valid namespaces, and Console won't be among them.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The using keyword can save a great deal of typing, but it can undermine the advantages of namespaces by polluting the scope with many undifferentiated names. A common solution is to use the using keyword with the built-in namespaces and with your own corporate namespaces, but perhaps not with third-party components.&lt;br /&gt;&lt;br /&gt; Some programming groups make it a policy to spell out the entire namespace path to the object (e.g., System.Console.WriteLine( ) and not Console.WriteLine()) as a form of documentation. This can become unworkable pretty quickly with deeply nested namespaces.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2.1.7. Case Sensitivity&lt;br /&gt;C# is case-sensitive, which means that writeLine is not the same as WriteLine, which in turn is not the same as WRITELINE. Unfortunately, unlike in VB, the C# development environment will not fix your case mistakes; if you write the same word twice with different cases, you might introduce a tricky-to-find bug into your program.&lt;br /&gt;&lt;br /&gt; A handy trick is to hover over a name that is correct in all but case and then hit Ctrl-Space. The Autocomplete feature of Intellisense will fix the case for you.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To prevent such a time-wasting and energy-depleting mistake, you should develop conventions for naming your variables, functions, constants, etc. The convention in this book is to name variables with camel notation (e.g., someVariableName), and to name functions, constants, and properties with Pascal notation (e.g., SomeFunction).&lt;br /&gt;&lt;br /&gt; The only difference between camel and Pascal notation is that in Pascal notation, names begin with an uppercase letter.&lt;br /&gt;&lt;br /&gt;Microsoft has developed code style guidelines that make a very good starting point (and often are all you need). You can download them from:&lt;br /&gt;&lt;br /&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconNETFrameworkDesignGuidelines.asp&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2.1.8. The static Keyword&lt;br /&gt;The Main( ) method shown in Example 2-1 has one more designation. Just before the return type declaration void (which, you will remember, indicates that the method doesn't return a value) you'll find the keyword static:&lt;br /&gt;&lt;br /&gt;static void Main()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The static keyword indicates that you can invoke Main( ) without first creating an object of type Hello. This somewhat complex issue will be considered in much greater detail in subsequent chapters. One of the problems with learning a new computer language is you must use some of the advanced features before you fully understand them. For now, you can treat the declaration of the Main( ) method as tantamount to magic.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-6996612339800526556?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/6996612339800526556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=6996612339800526556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6996612339800526556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6996612339800526556'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/10/2-getting-started-hello-world.html' title='2. Getting Started: &quot;Hello World&quot;'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-6772121811115267824</id><published>2008-10-09T23:56:00.000-07:00</published><updated>2008-10-09T23:57:19.486-07:00</updated><title type='text'>The C# Language</title><content type='html'>The C# language is disarmingly simple, with only about 80 keywords and a dozen built-in datatypes, but it's highly expressive when it comes to implementing modern programming concepts. C# includes all the support for structured, component- based, object-oriented programming that you expect of a modern language built on the shoulders of C++ and Java, and now with Version 2.0, many of the most important missing ingredients, such as generics and anonymous methods, have been added.&lt;br /&gt;&lt;br /&gt; C++ programmers take note: generics are the C# equivalent to Templates, though it turns out that C# generics are a bit simpler and more efficient than C++ templates; they reduce code bloat by reusing shared code at runtime, while giving up a bit of the flexibility available with C++ templates.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The C# language was developed by a small team led by two distinguished Microsoft engineers, Anders Hejlsberg and Scott Wiltamuth. Hejlsberg is also known for creating Turbo Pascal, a popular language for PC programming, and for leading the team that designed Borland Delphi, one of the first successful integrated development environments for client/server programming.&lt;br /&gt;&lt;br /&gt;At the heart of any object-oriented language is its support for defining and working with classes. Classes define new types, allowing you to extend the language to better model the problem you are trying to solve. C# contains keywords for declaring new classes and their methods and properties, and for implementing encapsulation, inheritance, and polymorphism, the three pillars of object-oriented programming.&lt;br /&gt;&lt;br /&gt;In C#, everything pertaining to a class declaration is found in the declaration itself. C# class definitions don't require separate header files or Interface Definition Language (IDL) files. Moreover, C# supports a new XML style of inline documentation that simplifies the creation of online and print reference documentation for an application.&lt;br /&gt;&lt;br /&gt;C# also supports interfaces, a means of making a contract with a class for services that the interface stipulates. In C#, a class can inherit from only a single parent, but a class can implement multiple interfaces. When it implements an interface, a C# class in effect promises to provide the functionality the interface specifies.&lt;br /&gt;&lt;br /&gt;C# also provides support for structs, a concept whose meaning has changed significantly from C++. In C#, a struct is a restricted, lightweight type that, when instantiated, makes fewer demands on the operating system and on memory than a conventional class does. A struct can't inherit from a class or be inherited from, but a struct can implement an interface.&lt;br /&gt;&lt;br /&gt;C# provides full support of delegates : to provide invocation of methods through indirection. In other languages, such as C++, you might find similar functionality (as in pointers to member functions), but delegates are type-safe reference types that encapsulate methods with specific signatures and return types.&lt;br /&gt;&lt;br /&gt;C# provides component-oriented features, such as properties, events, and declarative constructs (such as attributes). Component-oriented programming is supported by the storage of metadata with the code for the class. The metadata describes the class, including its methods and properties, as well as its security needs and other attributes, such as whether it can be serialized; the code contains the logic necessary to carry out its functions. A compiled class is thus a self-contained unit. Therefore, a hosting environment that knows how to read a class' metadata and code needs no other information to make use of it. Using C# and the CLR, it is possible to add custom metadata to a class by creating custom attributes. Likewise, it is possible to read class metadata using CLR types that support reflection.&lt;br /&gt;&lt;br /&gt;When you compile your code you create an assembly. An assembly is a collection of files that appear to the programmer to be a single dynamic link library (DLL) or executable (EXE). In .NET, an assembly is the basic unit of reuse, versioning, security, and deployment. The CLR provides a number of classes for manipulating assemblies.&lt;br /&gt;&lt;br /&gt;A final note about C# is that it also provides support for:&lt;br /&gt;&lt;br /&gt;Directly accessing memory using C++ style pointers&lt;br /&gt;&lt;br /&gt;Keywords for bracketing such operations as unsafe&lt;br /&gt;&lt;br /&gt;Warning the CLR garbage collector not to collect objects referenced by pointers until they are released&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-6772121811115267824?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/6772121811115267824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=6772121811115267824' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6772121811115267824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6772121811115267824'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/10/c-language.html' title='The C# Language'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-5595535788852640901</id><published>2008-10-09T23:50:00.000-07:00</published><updated>2008-10-09T23:51:08.546-07:00</updated><title type='text'></title><content type='html'>The most important component of the .NET Framework is the CLR, which provides the environment in which programs are executed. The CLR includes a virtual machine, analogous in many ways to the Java virtual machine. At a high level, the CLR activates objects, performs security checks on them, lays them out in memory, executes them, and garbage-collects them. (The Common Type System is also part of the CLR.)&lt;br /&gt;&lt;br /&gt;In Figure 1-1, the layer on top of the CLR is a set of framework classes, followed by an additional layer of data and XML classes, plus another layer of classes intended for web services, Web Forms, and Windows Forms. Collectively, these classes make up the FCL, one of the largest class libraries in history and one that provides an object-oriented API for all the functionality that the .NET platform encapsulates. With more than 4,000 classes, the FCL facilitates rapid development of desktop, client/server, and other web services and applications.&lt;br /&gt;&lt;br /&gt;The set of Framework base classes, the lowest level of the FCL, is similar to the set of classes in Java. These classes support input and output, string manipulation, security management, network communication, thread management, text manipulation, reflection and collections functionality, etc.&lt;br /&gt;&lt;br /&gt;Above this level is a tier of classes that extend the base classes to support data management and XML manipulation. The data classes support persistent management of data that is maintained on backend databases. These classes include the Structured Query Language (SQL) classes to let you manipulate persistent data stores through a standard SQL interface. The .NET Framework also supports a number of classes to let you manipulate XML data and perform XML searching and translations.&lt;br /&gt;&lt;br /&gt;Extending the Framework base classes and the data and XML classes is a tier of classes geared toward building applications using three different technologies: web services, Web Forms, and Windows Forms. Web services include a number of classes that support the development of lightweight distributed components, which will work even in the face of firewalls and NAT software. Because web services employ standard HTTP and SOAP as underlying communications protocols, these components support Plug and Play across cyberspace.&lt;br /&gt;&lt;br /&gt;Web Forms and Windows Forms allow you to apply Rapid Application Development (RAD) techniques to building web and Windows applications. Simply drag and drop controls onto your form, double-click a control, and write the code to respond to the associated event.&lt;br /&gt;&lt;br /&gt;For a more detailed description of the .NET Framework, see .NET Framework Essentials (O'Reilly).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-5595535788852640901?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/5595535788852640901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=5595535788852640901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/5595535788852640901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/5595535788852640901'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/10/most-important-component-of.html' title=''/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-9128361471575206567</id><published>2008-10-09T23:49:00.000-07:00</published><updated>2008-10-09T23:50:39.906-07:00</updated><title type='text'>The .NET Framework</title><content type='html'>Microsoft .NET supports not only language independence, but also language integration. This means that you can inherit from classes, catch exceptions, and take advantage of polymorphism across different languages. The .NET Framework makes this possible with a specification called the Common Type System (CTS) that all .NET components must obey. For example, everything in .NET is an object of a specific class that derives from the root class called System.Object. The CTS supports the general concept of classes, interfaces, and delegates (which support callbacks).&lt;br /&gt;&lt;br /&gt;Additionally, .NET includes a Common Language Specification (CLS), which provides a series of basic rules that are required for language integration. The CLS determines the minimum requirements for being a .NET language. Compilers that conform to the CLS create objects that can interoperate with one another. The entire Framework Class Library (FCL) can be used by any language that conforms to the CLS.&lt;br /&gt;&lt;br /&gt;The .NET Framework sits on top of the operating system, which can be any flavor of Windows,[1] and consists of a number of components, currently including:&lt;br /&gt;&lt;br /&gt;[1] Because of the architecture of the CLR, the operating system can be any variety of Unix or another operating system altogether.&lt;br /&gt;&lt;br /&gt;Five official languages: C#, VB, Visual C++, Visual J#, and JScript.NET&lt;br /&gt;&lt;br /&gt;The CLR, an object-oriented platform for Windows and web development that all these languages share&lt;br /&gt;&lt;br /&gt;A number of related class libraries, collectively known as the Framework Class Library&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-9128361471575206567?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/9128361471575206567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=9128361471575206567' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/9128361471575206567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/9128361471575206567'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/10/net-framework.html' title='The .NET Framework'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-4529624042273276756</id><published>2008-09-26T01:16:00.000-07:00</published><updated>2008-09-26T01:24:31.153-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vb.net'/><category scheme='http://www.blogger.com/atom/ns#' term='data reapeter'/><category scheme='http://www.blogger.com/atom/ns#' term='asp.net'/><title type='text'>C# and the .NET Framework</title><content type='html'>The goal of C# 2.0 is to provide a simple, safe, modern, object-oriented, Internet-centric, high-performance language for .NET development. C# is now a fully mature language, and it draws on the lessons learned over the past three decades. In much the way that you can see in young children the features and personalities of their parents and grandparents, you can easily see in C# the influence of Java, C++, Visual Basic (VB), and other languages, but you can also see the lessons learned since C# was first introduced.&lt;br /&gt;&lt;br /&gt;The focus of this book is the C# language and its use as a tool for programming on the .NET platform, specifically and especially with Visual Studio .NET 2005 (full or Express Edition).&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;1.1. The .NET Platform&lt;/span&gt;&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When Microsoft announced C# in July 2000, its unveiling was part of a much larger event: the announcement of the .NET platform. C# 2.0 represents the maturation of that language and coincides with the release of the next generation of tools for .NET.&lt;br /&gt;&lt;br /&gt;The .NET platform is a development framework that provides a new application programming interface (API) to the services and APIs of classic Windows operating systems while bringing together a number of disparate technologies that emerged from Microsoft during the late 1990s. This includes COM+ component services, a commitment to XML and object-oriented design, support for new web services protocols such as SOAP, WSDL, and UDDI, and a focus on the Internet, all integrated within the Distributed interNet Applications (DNA) architecture.&lt;br /&gt;&lt;br /&gt;Microsoft has devoted enormous resources to the development of .NET and its associated technologies. The results of this commitment to date are impressive. For one thing, the scope of .NET is huge. The platform consists of three product groups:&lt;br /&gt;&lt;br /&gt;A set of languages, including C# and VB, a set of development tools including Visual Studio .NET, a comprehensive class library for building web services and web and Windows applications, as well as the Common Language Runtime (CLR) to execute objects built within this framework&lt;br /&gt;&lt;br /&gt;Two generations of .NET Enterprise Servers: those already released and those to be released over the next 24-36 months&lt;br /&gt;&lt;br /&gt;New .NET-enabled non-PC devices, from cell phones to game boxes&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-4529624042273276756?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/4529624042273276756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=4529624042273276756' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/4529624042273276756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/4529624042273276756'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/09/asp-data-repeater.html' title='C# and the .NET Framework'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-6579918223665688767</id><published>2008-07-02T04:05:00.000-07:00</published><updated>2008-07-02T04:07:16.908-07:00</updated><title type='text'>Passing value from popup window to parent form's TextBox</title><content type='html'>Once again seen lot of questions on the forum related to passing values from popup window to the parent form textbox. Specially when they have some GridView type control in the popup. In the following example I will be using two forms, parent form will be parent.aspx and popup will be popup.aspx. Also note that my parent.aspx form is derived from some MasterPage. Code is provided both in VB.Net and C#.Net.&lt;br /&gt;&lt;br /&gt;--- .aspx of parent form ---&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;        function OpenPopup()&lt;br /&gt;        {&lt;br /&gt;            window.open("popup.aspx","List","scrollbars=no,resizable=no,width=400,height=280");&lt;br /&gt;            return false;&lt;br /&gt;        }&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;asp:textbox id="txtPopupValue" runat="server" width="327px"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;    &lt;asp:button id="Button1" runat="server" text="Show List"&gt;&lt;br /&gt;&lt;br /&gt;--- .vb of parent.aspx if vb.net is the language ---&lt;br /&gt;&lt;br /&gt;If Not IsPostBack Then&lt;br /&gt; Me.Button1.Attributes.Add("onclick", "javascript:return OpenPopup()")&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;--- .cs of parent.aspx if C#.net is the language ---&lt;br /&gt;&lt;br /&gt;if !(IsPostBack)&lt;br /&gt;{&lt;br /&gt; this.Button1.Attributes.Add("onclick", "javascript:return OpenPopup()");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;--- .aspx of popup form ---&lt;br /&gt;&lt;br /&gt;&lt;script language="javascript"&gt;&lt;br /&gt;        function GetRowValue(val)&lt;br /&gt;        {&lt;br /&gt;            window.opener.document.getElementById("ctl00_ContentPlaceHolder1_TextBox2").value = val; //hardcoded value used to minimize the code. ControlID can be passed as query string to the popup window&lt;br /&gt;            window.close();&lt;br /&gt;        }&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;asp:gridview id="GridView1" runat="server" datasourceid="SqlDataSource1" width="400px" allowpaging="True"&gt;&lt;br /&gt;            &lt;columns&gt;&lt;br /&gt;                &lt;asp:templatefield&gt;&lt;br /&gt;                    &lt;alternatingitemtemplate&gt;&lt;br /&gt;                        &lt;asp:button id="btnSelect" runat="server" text="Select"&gt;&lt;br /&gt;                    &lt;/alternatingitemtemplate&gt;&lt;br /&gt;                    &lt;itemtemplate&gt;&lt;br /&gt;                        &lt;asp:button id="btnSelect" runat="server" text="Select"&gt;&lt;br /&gt;                    &lt;/itemtemplate&gt;&lt;br /&gt;                &lt;/asp:TemplateField&gt;&lt;br /&gt;            &lt;/columns&gt;&lt;br /&gt;        &lt;/asp:GridView&gt;&lt;br /&gt;&lt;br /&gt;--- .vb file if vb.net is the language ---&lt;br /&gt;&lt;br /&gt;Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound&lt;br /&gt;        If (e.Row.RowType = DataControlRowType.DataRow) Then&lt;br /&gt;            DirectCast(e.Row.FindControl("btnSelect"), Button).Attributes.Add("onclick", "javascript:GetRowValue('" &amp;amp; e.Row.Cells(1).Text &amp;amp; "')") 'assuming that the required value column is the second column in gridview&lt;br /&gt;        End If&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;--- .cs file if C#.net is the language ---&lt;br /&gt;&lt;br /&gt;protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) &lt;br /&gt;{ &lt;br /&gt;    if ((e.Row.RowType == DataControlRowType.DataRow)) { &lt;br /&gt;        ((Button)e.Row.FindControl("btnSelect")).Attributes.Add("onclick", "javascript:GetRowValue('" + e.Row.Cells(1).Text + "')"); &lt;br /&gt;        //assuming that the required value column is the second column in gridview &lt;br /&gt;    } &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;I hope the code above is straight forward and easy to understand.&lt;br /&gt;&lt;br /&gt;Happy Coding!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-6579918223665688767?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/6579918223665688767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=6579918223665688767' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6579918223665688767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6579918223665688767'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/07/passing-value-from-popup-window-to.html' title='Passing value from popup window to parent form&apos;s TextBox'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-6622811425076663997</id><published>2008-07-02T04:03:00.000-07:00</published><updated>2008-07-02T04:05:03.560-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='vb.net'/><category scheme='http://www.blogger.com/atom/ns#' term='asp.net'/><category scheme='http://www.blogger.com/atom/ns#' term='.net 2.0'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Login Through Cookies</title><content type='html'>Different forums are filled with the questions regarding how to manually implement cookies for login or in other words how to implement "Remeber me" option. &lt;br /&gt;&lt;br /&gt;Following is the code that will give the idea of how to achieve this task.&lt;br /&gt;&lt;br /&gt;Controls used&lt;br /&gt;1. TextBox, ID = TbUserName&lt;br /&gt;2. TextBox, ID = TbPassword&lt;br /&gt;3. CheckBox, ID = CbRememberMe&lt;br /&gt;4. Button, ID = BtLogin&lt;br /&gt;5. LinkButton, ID = lbSignout&lt;br /&gt;&lt;br /&gt;------------------If you are using VB.Net-------------------------&lt;br /&gt;&lt;br /&gt;Partial Class _Default&lt;br /&gt;    Inherits System.Web.UI.Page&lt;br /&gt;&lt;br /&gt;    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load&lt;br /&gt;        If Not IsPostBack Then&lt;br /&gt;            'Check if the browser support cookies&lt;br /&gt;            If Request.Browser.Cookies Then&lt;br /&gt;               'Check if the cookies with name PBLOGIN exist on user's machine&lt;br /&gt;                If Request.Cookies("PBLOGIN") IsNot Nothing Then&lt;br /&gt;                    'Pass the user name and password to the VerifyLogin method&lt;br /&gt;                    Me.VerifyLogin(Request.Cookies("PBLOGIN")("UNAME").ToString(), Request.Cookies("PBLOGIN")("UPASS").ToString())&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;    Protected Sub BtLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs)&lt;br /&gt;        'check if remember me checkbox is checked on login&lt;br /&gt;        If (Me.CbRememberMe.Checked) Then&lt;br /&gt;            'Check if the browser support cookies&lt;br /&gt;            If (Request.Browser.Cookies) Then&lt;br /&gt;                'Check if the cookie with name PBLOGIN exist on user's machine&lt;br /&gt;                If (Request.Cookies("PBLOGIN") Is Nothing) Then&lt;br /&gt;                    'Create a cookie with expiry of 30 days&lt;br /&gt;                    Response.Cookies("PBLOGIN").Expires = DateTime.Now.AddDays(30)&lt;br /&gt;                    'Write username to the cookie&lt;br /&gt;                    Response.Cookies("PBLOGIN").Item("UNAME") = Me.TbUserName.Text&lt;br /&gt;                    'Write password to the cookie&lt;br /&gt;                    Response.Cookies("PBLOGIN").Item("UPASS") = Me.TbPassword.Text&lt;br /&gt;  'If the cookie already exist then wirte the user name and password on the cookie&lt;br /&gt;                Else&lt;br /&gt;                    Response.Cookies("PBLOGIN").Item("UNAME") = Me.TbUserName.Text&lt;br /&gt;                    Response.Cookies("PBLOGIN").Item("UPASS") = Me.TbPassword.Text&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        Me.VerifyLogin(Me.TbUserName.Text, Me.TbPassword.Text)&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;    Protected Sub VerifyLogin(ByVal UserName As String, ByVal Password As String)&lt;br /&gt;        Try&lt;br /&gt;            'If login credentials are correct&lt;br /&gt;                 'Redirect to the user page&lt;br /&gt;            'else&lt;br /&gt;                 'prompt user for invalid password&lt;br /&gt;            'end if&lt;br /&gt;        Catch ex as System.Exception&lt;br /&gt;            Response.Write(ex.Message)&lt;br /&gt;        End Try&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;    Protected Sub lbSignout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbSignout.Click&lt;br /&gt; 'Check iIf the cookies with name PBLOGIN exist on user's machine&lt;br /&gt;        If (Request.Cookies("PBLOGIN") IsNot Nothing) Then&lt;br /&gt;            'Expire the cookie&lt;br /&gt;            Response.Cookies("PBLOGIN").Expires = DateTime.Now.AddDays(-30)&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        'Redirect to the login page&lt;br /&gt;    End Sub&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;------------------If you are using C#.Net-------------------------&lt;br /&gt;&lt;br /&gt;partial class _Default : System.Web.UI.Page &lt;br /&gt;{ &lt;br /&gt;    &lt;br /&gt;    protected void Page_Load(object sender, System.EventArgs e) &lt;br /&gt;    { &lt;br /&gt;        if (!IsPostBack) &lt;br /&gt;        { &lt;br /&gt;            //Check if the browser support cookies &lt;br /&gt;            if (Request.Browser.Cookies) &lt;br /&gt;            { &lt;br /&gt;                //Check if the cookies with name PBLOGIN exist on user's machine &lt;br /&gt;                if (Request.Cookies("PBLOGIN") != null) &lt;br /&gt;                { &lt;br /&gt;                    //Pass the user name and password to the VerifyLogin method &lt;br /&gt;                    this.VerifyLogin(Request.Cookies("PBLOGIN")("UNAME").ToString(), Request.Cookies("PBLOGIN")("UPASS").ToString()); &lt;br /&gt;                } &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;    } &lt;br /&gt;    &lt;br /&gt;    protected void BtLogin_Click(object sender, System.EventArgs e) &lt;br /&gt;    { &lt;br /&gt;        //check if remember me checkbox is checked on login &lt;br /&gt;        if ((this.CbRememberMe.Checked)) &lt;br /&gt;        { &lt;br /&gt;            //Check if the browser support cookies &lt;br /&gt;            if ((Request.Browser.Cookies)) &lt;br /&gt;            { &lt;br /&gt;                //Check if the cookie with name PBLOGIN exist on user's machine &lt;br /&gt;                if ((Request.Cookies("PBLOGIN") == null)) &lt;br /&gt;                { &lt;br /&gt;                    //Create a cookie with expiry of 30 days &lt;br /&gt;                    Response.Cookies("PBLOGIN").Expires = DateTime.Now.AddDays(30); &lt;br /&gt;                    //Write username to the cookie &lt;br /&gt;                    Response.Cookies("PBLOGIN").Item("UNAME") = this.TbUserName.Text; &lt;br /&gt;                    //Write password to the cookie &lt;br /&gt;                    Response.Cookies("PBLOGIN").Item("UPASS") = this.TbPassword.Text; &lt;br /&gt;                } &lt;br /&gt;                //If the cookie already exist then wirte the user name and password on the cookie &lt;br /&gt;                else &lt;br /&gt;                { &lt;br /&gt;                    Response.Cookies("PBLOGIN").Item("UNAME") = this.TbUserName.Text; &lt;br /&gt;                    Response.Cookies("PBLOGIN").Item("UPASS") = this.TbPassword.Text; &lt;br /&gt;                } &lt;br /&gt;            } &lt;br /&gt;        } &lt;br /&gt;        &lt;br /&gt;        this.VerifyLogin(this.TbUserName.Text, this.TbPassword.Text); &lt;br /&gt;    } &lt;br /&gt;    &lt;br /&gt;    protected void VerifyLogin(string UserName, string Password) &lt;br /&gt;    { &lt;br /&gt;        try &lt;br /&gt;        { &lt;br /&gt;             //If login credentials are correct &lt;br /&gt;                  //Redirect to the user page &lt;br /&gt;             //else &lt;br /&gt;                  //prompt user for invalid password &lt;br /&gt;             //end if&lt;br /&gt;        } &lt;br /&gt;        catch (System.Exception ex)&lt;br /&gt;        { &lt;br /&gt;            Response.Write(ex.Message); &lt;br /&gt;        } &lt;br /&gt;    } &lt;br /&gt;    &lt;br /&gt;    protected void lbSignout_Click(object sender, System.EventArgs e) &lt;br /&gt;    { &lt;br /&gt;        //Check iIf the cookies with name PBLOGIN exist on user's machine &lt;br /&gt;        if ((Request.Cookies("PBLOGIN") != null))&lt;br /&gt;        { &lt;br /&gt;            //Expire the cookie &lt;br /&gt;            Response.Cookies("PBLOGIN").Expires = DateTime.Now.AddDays(-30); &lt;br /&gt;        } &lt;br /&gt;        &lt;br /&gt;        //Redirect to the login page &lt;br /&gt;    } &lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-6622811425076663997?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/6622811425076663997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=6622811425076663997' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6622811425076663997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/6622811425076663997'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/07/login-through-cookies.html' title='Login Through Cookies'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-163936697130312525.post-224507536222910031</id><published>2008-06-30T03:36:00.003-07:00</published><updated>2008-06-30T03:36:32.949-07:00</updated><title type='text'>Hi...</title><content type='html'>Hi...to blog..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/163936697130312525-224507536222910031?l=srihariatthuluri.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://srihariatthuluri.blogspot.com/feeds/224507536222910031/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=163936697130312525&amp;postID=224507536222910031' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/224507536222910031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/163936697130312525/posts/default/224507536222910031'/><link rel='alternate' type='text/html' href='http://srihariatthuluri.blogspot.com/2008/06/hi_30.html' title='Hi...'/><author><name>srihari</name><uri>http://www.blogger.com/profile/01313053731459618172</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp1.blogger.com/_ZNd2kGbiBNE/SFZeMNYxrAI/AAAAAAAAAA4/ZcmAVMQXEJw/S220/ATcAAABnXjMnOxNI9ChDj2lMAXCi2Nxcg3lZlmVJ0nstcrhxUfVlKT6P-A_rZSp0yefxaVQ5EiWy87PUHQygn4WmhgHhAJtU9VCkjyzNma_Bs6PfdGQKJE4XJ1tR7w.jpg'/></author><thr:total>0</thr:total></entry></feed>
