<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-35664843</atom:id><lastBuildDate>Fri, 06 Mar 2026 11:21:02 +0000</lastBuildDate><title>Welcome to the amazing dot net programming</title><description>dotnetbeauty blog is an online resource blog for ASP and ASP.NET information! Find out the ASP,ASP.NET articles, FAQ&#39;s and related articles on the microsoft technology.</description><link>http://dotnetlibrary.blogspot.com/</link><managingEditor>noreply@blogger.com (Vijay Kumar)</managingEditor><generator>Blogger</generator><openSearch:totalResults>56</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-117154412861476667</guid><pubDate>Thu, 15 Feb 2007 12:54:00 +0000</pubDate><atom:updated>2007-02-15T04:55:29.726-08:00</atom:updated><title>C++ Faq</title><description>Before coming to the C++ faq, here i am adding some quick reference to the C++ syntax and tutorial. I know it&#39;s not related to .Net but as we know the concepts for C# and C++ is same. Hope that this faq will be helpful for devlopers who are working on both the languages C# and C++&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You can follow at&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.hoomanb.com/cs/QuickRef/CppQuickRef.pdf&quot;&gt;C++ Quick reference&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href=&quot;http://www.pragsoft.com/books/CppEssentials.pdf&quot;&gt;C++ Essentials Tutorial&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p align=&quot;center&quot;&gt;&lt;br /&gt;C++ FAQ&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is encapsulation?&lt;/span&gt;&lt;br /&gt;Containing and hiding information about an object, such as internal data structures and code. Encapsulation isolates the internal complexity of an objects operation from the rest of the application. For example, a client component asking for net revenue from a business object need not know the datas origin.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is inheritance?&lt;/span&gt;&lt;br /&gt;Inheritance allows one class to reuse the state and behavior of another class. The derived class inherits the properties and method implementations of the base class and extends it by overriding methods and adding additional properties and methods.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is Polymorphism?&lt;/span&gt;&lt;br /&gt;Polymorphism allows a client to treat different objects in the same way even if they were created from different classes and exhibit different behaviors. You can use implementation inheritance to achieve polymorphism in languages such as C++ and Java. Base class objects pointer can invoke methods in derived class objects. You can also achieve polymorphism in C++ by function overloading and operator overloading.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is constructor or ctor? &lt;/span&gt;&lt;br /&gt;Constructor creates an object and initializes it. It also creates vtable for virtual&lt;br /&gt;functions. It is different from other methods in a class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is destructor?&lt;/span&gt;&lt;br /&gt;Destructor usually deletes any extra resources allocated by the object.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is default constructor?&lt;/span&gt;&lt;br /&gt;Constructor with no arguments or all the arguments has default values.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is copy constructor?&lt;/span&gt;&lt;br /&gt;Constructor which initializes the it&#39;s object member variables ( by shallow copying) with another object of the same class. If you don&#39;t implement one in your class then compiler implements one for you.&lt;br /&gt;for example:&lt;br /&gt;Boo Obj1(10); // calling Boo constructor&lt;br /&gt;Boo Obj2(Obj1); // calling boo copy constructor&lt;br /&gt;Boo Obj2 = Obj1;// calling boo copy constructor&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;When are copy constructors called?&lt;/span&gt;&lt;br /&gt;Copy constructors are called in following cases:&lt;br /&gt;a) when a function returns an object of that class by value&lt;br /&gt;b) when the object of that class is passed by value as an argument to a function&lt;br /&gt;c) when you construct an object based on another object of the same class&lt;br /&gt;d) When compiler generates a temporary object&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is assignment operator?&lt;/span&gt;&lt;br /&gt;Default assignment operator handles assigning one object to another of the same class. Member to member copy (shallow copy)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What are all the implicit member functions of the class? Or what are all the functions which compiler implements for us if we dont define one.?&lt;/span&gt;&lt;br /&gt;default ctor&lt;br /&gt;copy ctor&lt;br /&gt;assignment operator&lt;br /&gt;default destructor&lt;br /&gt;address operator&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is conversion constructor?&lt;/span&gt;&lt;br /&gt;constructor with a single argument makes that constructor as conversion ctor and it can be used for type conversion.&lt;br /&gt;for example:&lt;br /&gt;class Boo&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;Boo( int i );&lt;br /&gt;};&lt;br /&gt;Boo BooObject = 10 ; // assigning int 10 Boo object&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is conversion operator?&lt;/span&gt;&lt;br /&gt;class can have a public method for specific data type conversions.&lt;br /&gt;for example:&lt;br /&gt;class Boo&lt;br /&gt;{&lt;br /&gt;double value;&lt;br /&gt;public:&lt;br /&gt;Boo(int i )&lt;br /&gt;operator double()&lt;br /&gt;{&lt;br /&gt;return value;&lt;br /&gt;}&lt;br /&gt;};&lt;br /&gt;Boo BooObject;&lt;br /&gt;double i = BooObject; // assigning object to variable i of type double. now conversion&lt;br /&gt;operator gets called to assign the value.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is diff between malloc()/free() and new/delete?&lt;/span&gt;&lt;br /&gt;malloc allocates memory for object in heap but doesn&#39;t invoke object&#39;s constructor to&lt;br /&gt;initiallize the object.&lt;br /&gt;new allocates memory and also invokes constructor to initialize the object.&lt;br /&gt;malloc() and free() do not support object semantics&lt;br /&gt;Does not construct and destruct objects&lt;br /&gt;string * ptr = (string *)(malloc (sizeof(string)))&lt;br /&gt;Are not safe &lt;br /&gt;Does not calculate the size of the objects that it construct Returns a pointer to void&lt;br /&gt;int *p = (int *) (malloc(sizeof(int)));&lt;br /&gt;int *p = new int;&lt;br /&gt;Are not extensible&lt;br /&gt;new and delete can be overloaded in a class&lt;br /&gt;&quot;delete&quot; first calls the object&#39;s termination routine (i.e. its destructor) and then&lt;br /&gt;releases the space the object occupied on the heap memory. If an array of objects was&lt;br /&gt;created using new, then delete must be told that it is dealing with an array by preceding&lt;br /&gt;the name with an empty []:-&lt;br /&gt;Int_t *my_ints = new Int_t[10];&lt;br /&gt;...&lt;br /&gt;delete []my_ints;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is the diff between &quot;new&quot; and &quot;operator new&quot;? &lt;/span&gt;&lt;br /&gt;&quot;operator new&quot; works like malloc.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is difference between template and macro?&lt;/span&gt;&lt;br /&gt;There is no way for the compiler to verify that the macro parameters are of compatible types. The macro is expanded without any special type checking.&lt;br /&gt;If macro parameter has a postincremented variable ( like c++ ), the increment is performed two times.&lt;br /&gt;Because macros are expanded by the preprocessor, compiler error messages will refer to the expanded macro, rather than the macro definition itself. Also, the macro will show up in expanded form during debugging.&lt;br /&gt;for example:&lt;br /&gt;Macro:&lt;br /&gt;#define min(i, j) (i &lt;&gt; T min (T i, T j)&lt;br /&gt;{&lt;br /&gt;return i &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span color=&quot;red&quot;&gt;What are C++ storage classes?&lt;/span&gt;&lt;br /&gt;auto&lt;br /&gt;register&lt;br /&gt;static&lt;br /&gt;extern&lt;br /&gt;&lt;br /&gt;auto: the default. Variables are automatically created and initialized when they are defined and are destroyed at the end of the block containing their definition. They are not visible outside that block&lt;br /&gt;&lt;br /&gt;register: a type of auto variable. a suggestion to the compiler to use a CPU register for performance&lt;br /&gt;&lt;br /&gt;static: a variable that is known only in the function that contains its definition but is never destroyed and retains its value between calls to that function. It exists from the time the program begins execution&lt;br /&gt;&lt;br /&gt;extern: a static variable whose definition and placement is determined when all object and library modules are combined (linked) to form the executable code file. It can be visible outside the file where it is defined.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What are storage qualifiers in C++ ? &lt;/span&gt;&lt;br /&gt;They are..&lt;br /&gt;const&lt;br /&gt;volatile&lt;br /&gt;mutable&lt;br /&gt;&lt;br /&gt;Const keyword indicates that memory once initialized, should not be altered by a program.&lt;br /&gt;&lt;br /&gt;volatile keyword indicates that the value in the memory location can be altered even though nothing in the program code modifies the contents. for example if you have a pointer to hardware location that contains the time, where hardware changes the value of this pointer variable and not the program. The intent of this keyword to improve the optimization ability of the compiler.&lt;br /&gt;&lt;br /&gt;mutable keyword indicates that particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.&lt;br /&gt;&lt;br /&gt;struct data&lt;br /&gt;{&lt;br /&gt;char name[80];&lt;br /&gt;mutable double salary;&lt;br /&gt;}&lt;br /&gt;const data MyStruct = { &quot;Satish Shetty&quot;, 1000 }; //initlized by complier&lt;br /&gt;strcpy ( MyStruct.name, &quot;Shilpa Shetty&quot;); // compiler error&lt;br /&gt;MyStruct.salaray = 2000 ; // complier is happy allowed&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is reference ? &lt;/span&gt;&lt;br /&gt;reference is a name that acts as an alias, or alternative name, for a previously defined variable or an object. prepending variable with &quot;&amp;&quot; symbol makes it as reference.&lt;br /&gt;for example:&lt;br /&gt;int a;&lt;br /&gt;int &amp;b = a;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is reference ? &lt;/span&gt;&lt;br /&gt;Method of passing arguments to a function which takes parameter of type reference. for&lt;br /&gt;example:&lt;br /&gt;void swap( int &amp; x, int &amp;amp; y )&lt;br /&gt;{&lt;br /&gt;int temp = x;&lt;br /&gt;x = y;&lt;br /&gt;y = x;&lt;br /&gt;}&lt;br /&gt;int a=2, b=3;&lt;br /&gt;swap( a, b );&lt;br /&gt;Basically, inside the function there won&#39;t be any copy of the arguments &quot;x&quot; and &quot;y&quot; instead they refer to original variables a and b. so no extra memory needed to pass arguments and it is more efficient.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;When do use &quot;const&quot; reference arguments in function?&lt;br /&gt; &lt;/span&gt;&lt;br /&gt;a) Using const protects you against programming errors that inadvertently alter data.&lt;br /&gt;b) Using const allows function to process both const and non-const actual arguments, while a function without const in the prototype can only accept non constant arguments.&lt;br /&gt;c) Using a const reference allows the function to generate and use a temporary variable appropriately.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;When are temporary variables created by C++ compiler? &lt;/span&gt;&lt;br /&gt;Provided that function parameter is a &quot;const reference&quot;, compiler generates temporary &lt;br /&gt;variable in following 2 ways. &lt;br /&gt;a) The actual argument is the correct type, but it isn&#39;t Lvalue&lt;br /&gt;double Cuberoot ( const double &amp; num )&lt;br /&gt;{&lt;br /&gt;num = num * num * num;&lt;br /&gt;return num;&lt;br /&gt;}&lt;br /&gt;double temp = 2.0;&lt;br /&gt;double value = cuberoot ( 3.0 + temp ); // argument is a expression and not a Lvalue;&lt;br /&gt;b) The actual argument is of the wrong type, but of a type that can be converted to the &lt;br /&gt;correct type&lt;br /&gt;long temp = 3L;&lt;br /&gt;double value = cuberoot ( temp); // long to double conversion &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is virtual function?&lt;/span&gt;&lt;br /&gt;When derived class overrides the base class method by redefining the same function, then if client wants to access redefined the method from derived class through a pointer from base class object, then you must define this function in base class as virtual function.&lt;br /&gt;class parent&lt;br /&gt;{&lt;br /&gt;void Show() &lt;br /&gt;{ &lt;br /&gt;cout &lt;&lt; &quot;i&#39;m parent&quot; &lt;&lt; endl;&lt;br /&gt;}&lt;br /&gt;};&lt;br /&gt;class child: public parent&lt;br /&gt;{&lt;br /&gt;void Show() &lt;br /&gt;{ &lt;br /&gt;cout &lt;&lt; &quot;i&#39;m child&quot; &lt;&lt; endl;&lt;br /&gt;}&lt;br /&gt;};&lt;br /&gt;parent * parent_object_ptr = new child;&lt;br /&gt;parent_object_ptr-&gt;show() // calls parent-&gt;show() i &lt;br /&gt;now we goto virtual world...&lt;br /&gt;class parent&lt;br /&gt;{&lt;br /&gt;virtual void Show() &lt;br /&gt;{ &lt;br /&gt;cout &lt;&lt; &quot;i&#39;m parent&quot; &lt;&lt; endl;&lt;br /&gt;}&lt;br /&gt;};&lt;br /&gt;class child: public parent&lt;br /&gt;{&lt;br /&gt;void Show() &lt;br /&gt;{ &lt;br /&gt;cout &lt;&lt; &quot;i&#39;m child&quot; &lt;&lt; endl;&lt;br /&gt;}&lt;br /&gt;};&lt;br /&gt;parent * parent_object_ptr = new child;&lt;br /&gt;parent_object_ptr-&gt;show() // calls child-&gt;show() &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is pure virtual function? or what is abstract class?&lt;/span&gt;&lt;br /&gt;When you define only function prototype in a base class without and do the complete &lt;br /&gt;implementation in derived class. This base class is called abstract class and client won&#39;t able to instantiate an object using this base class.&lt;br /&gt;You can make a pure virtual function or abstract class this way.. &lt;br /&gt;class Boo&lt;br /&gt;{&lt;br /&gt;void foo() = 0;&lt;br /&gt;}&lt;br /&gt;Boo MyBoo; // compilation error&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is Memory alignment?&lt;/span&gt;&lt;br /&gt;The term alignment primarily means the tendency of an address pointer value to be a multiple of some power of two. So a pointer with two byte alignment has a zero in the least significant bit. And a pointer with four byte alignment has a zero in both the two least significant bits. And so on. More alignment means a longer sequence of zero bits in the lowest bits of a pointer.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What problem does the namespace feature solve? &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions. &lt;br /&gt;namespace [identifier] { namespace-body }&lt;br /&gt;A namespace declaration identifies and assigns a name to a declarative region.&lt;br /&gt;The identifier in a namespace declaration must be unique in the declarative region in which it is used. The identifier is the name of the namespace and is used to reference its members.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is the use of &#39;using&#39; declaration? &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;A using declaration makes it possible to use a name from a namespace without the scope operator. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is an Iterator class? &lt;/span&gt;&lt;br /&gt;A class that is used to traverse through the objects maintained by a container class. There are five categories of iterators: input iterators, output iterators, forward iterators, bidirectional iterators, random access. An iterator is an entity that gives access to the contents of a container object without violating encapsulation constraints. Access to the contents is granted on a one-at-a-time basis in order. The order can be storage order (as in lists and queues) or some arbitrary order (as in array indices) or according to some ordering relation (as in an ordered binary tree). The iterator is a construct, which provides an interface that, when called, yields either the next element in the container, or some value denoting the fact that there are no more elements to examine. Iterators hide the &lt;br /&gt;details of access to and update of the elements of a container class. Something like a pointer. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is a dangling pointer? &lt;/span&gt;&lt;br /&gt;A dangling pointer arises when you use the address of an object after its lifetime is over. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is a dangling pointer? &lt;/span&gt;&lt;br /&gt;It is a process during exception handling when the destructor is called for all local objects in the stack between the place where the exception was thrown and where it is caught.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;Name the operators that cannot be overloaded? &lt;/span&gt;&lt;br /&gt;sizeof, ., .*, .-&gt;, ::, ?: &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is a container class? What are the types of container classes? &lt;/span&gt;&lt;br /&gt;A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is inline function?&lt;/span&gt;&lt;br /&gt;The __inline keyword tells the compiler to substitute the code within the function &lt;br /&gt;definition for every instance of a function call. However, substitution occurs only at the compiler&#39;s discretion. For example, the compiler does not inline a function if its address is taken or if it is too large to inline.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is overloading?&lt;/span&gt;&lt;br /&gt;With the C++ language, you can overload functions and operators. Overloading is the practice of supplying more than one definition for a given function name in the same scope.&lt;br /&gt;- Any two functions in a set of overloaded functions must have different argument lists.&lt;br /&gt;- Overloading functions with argument lists of the same types, based on return type alone, is an error. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is Overriding?&lt;/span&gt;&lt;br /&gt;To override a method, a subclass of the class that originally declared the method must declare a method with the same name, return type (or a subclass of that return type), and same parameter list.&lt;br /&gt;The definition of the method overriding is: &lt;br /&gt;• Must have same method name. &lt;br /&gt;• Must have same data type. &lt;br /&gt;• Must have same argument list. &lt;br /&gt;Overriding a method means that replacing a method functionality in child class. To imply overriding functionality we need parent and child classes. In the child class you define the same method signature as one defined in the parent class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is &quot;this&quot; pointer?&lt;/span&gt;&lt;br /&gt;The this pointer is a pointer accessible only within the member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer.&lt;br /&gt;When a nonstatic member function is called for an object, the address of the object is passed as a hidden argument to the function. For example, the following function call myDate.setMonth( 3 );&lt;br /&gt;can be interpreted this way:&lt;br /&gt;setMonth( &amp;myDate, 3 );&lt;br /&gt;The object&#39;s address is available from within the member function as the this pointer. It is legal, though unnecessary, to use the this pointer when referring to members of the class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What happens when you make call &quot;delete this;&quot; ?&lt;/span&gt;&lt;br /&gt;The code has two built-in pitfalls. First, if it executes in a member function for an extern, static, or automatic object, the program will probably crash as soon as the delete statement executes. There is no portable way for an object to tell that it was instantiated on the heap, so the class cannot assert that its object is properly instantiated. Second, when an object commits suicide this way, the using program might not know about its demise. As far as the instantiating program is concerned, the object remains in scope and continues to exist even though the object did itself in. Subsequent dereferencing of the pointer can and usually does lead to disaster. You should never do this. Since compiler does not know whether the object was allocated on the stack or on the heap, &quot;delete this&quot; could cause a disaster.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;How virtual functions are implemented C++?&lt;/span&gt;&lt;br /&gt;Virtual functions are implemented using a table of function pointers, called the vtable. There is one entry in the table per virtual function in the class. This table is created by the constructor of the class. When a derived class is constructed, its base class is constructed first which creates the vtable. If the derived class overrides any of the base classes virtual functions, those entries in the vtable are overwritten by the derived class constructor. This is why you should never call virtual functions from a constructor: because the vtable entries for the object may not have been set up by the derived class constructor yet, so you might end up calling base class implementations of those virtual functions&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is name mangling in C++?&lt;/span&gt;&lt;br /&gt;The process of encoding the parameter types with the function/method name into a unique name is called name mangling. The inverse process is called demangling.&lt;br /&gt;For example Foo::bar(int, long) const is mangled as `bar__C3Fooil&#39;. &lt;br /&gt;For a constructor, the method name is left out. That is Foo::Foo(int, long) const is mangled as `__C3Fooil&#39;.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is the difference between a pointer and a reference? &lt;/span&gt;&lt;br /&gt;A reference must always refer to some object and, therefore, must always be initialized; pointers do not have such restrictions. A pointer can be reassigned to point to different objects while a reference always refers to an object with which it was initialized.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;How are prefix and postfix versions of operator++() differentiated?  &lt;/span&gt;&lt;br /&gt;The postfix version of operator++() has a dummy parameter of type int. The prefix version does not have dummy parameter.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is the difference between const char *myPointer and char *const myPointer? &lt;/span&gt;&lt;br /&gt;Const char *myPointer is a non constant pointer to constant data; while char *const &lt;br /&gt;myPointer is a constant pointer to non constant data. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;How can I handle a constructor that fails?&lt;/span&gt;&lt;br /&gt;throw an exception. Constructors don&#39;t have a return type, so it&#39;s not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;How can I handle a destructor that fails?&lt;/span&gt;&lt;br /&gt;Write a message to a log-file. But do not throw an exception. &lt;br /&gt;The C++ rule is that you must never throw an exception from a destructor that is being called during the &quot;stack unwinding&quot; process of another exception. For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get popped. This is called stack unwinding. &lt;br /&gt;During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a } catch (Bar e) { handler? There is no good answer -- either choice loses information. &lt;br /&gt;So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you&#39;re dead. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is Virtual Destructor?&lt;/span&gt;&lt;br /&gt;Using virtual destructors, you can destroy objects without knowing their type - the correct destructor for the object is invoked using the virtual function mechanism. Note that destructors can also be declared as pure virtual functions for abstract classes. if someone will derive from your class, and if someone will say &quot;new Derived&quot;, where &quot;Derived&quot; is derived from your class, and if someone will say delete p, where the actual object&#39;s type is &quot;Derived&quot; but the pointer p&#39;s type is your class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;Can you think of a situation where your program would crash without reaching the breakpoint which you set at the beginning of main()?&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;C++ allows for dynamic initialization of global variables before main() is invoked. It is possible that initialization of global will invoke some function. If this function crashes the crash will occur before main() is entered. &lt;br /&gt;Name two cases where you MUST use initialization list as opposed to assignment in &lt;br /&gt;constructors.&lt;br /&gt;Both non-static const data members and reference data members cannot be assigned values; instead, you should use initialization list to initialize them. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;Can you overload a function based only on whether a parameter is a value or a reference?&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;No. Passing by value and by reference looks identical to the caller. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What are the differences between a C++ struct and C++ class?&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The default member and base class access specifiers are different. &lt;br /&gt;The C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base class inheritance, and a class defaults to the private access specifier and private base class inheritance. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What does extern &quot;C&quot; int func(int *, Foo) accomplish?&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;It will turn off &quot;name mangling&quot; for func so that one can link to code compiled by a C compiler. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;How do you access the static member of a class?&lt;/span&gt;&lt;br /&gt;&lt;ClassName&gt;::&lt;StaticMemberName&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages?&lt;/span&gt;&lt;br /&gt;Multiple Inheritance is the process whereby a child can be derived from more than one parent class. The advantage of multiple inheritance is that it allows a class to inherit the functionality of more than one base class thus allowing for modeling of complex relationships. The disadvantage of multiple inheritance is that it can lead to a lot of confusion(ambiguity) when two base classes implement a method with the same name. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What are the access privileges in C++? What is the default access level?&lt;/span&gt;&lt;br /&gt;The access privileges in C++ are private, public and protected. The default access level assigned to members of a class is private. Private members of a class are accessible only within the class and by friends of the class. Protected members are accessible by the class itself and it&#39;s sub-classes. Public members of a class can be accessed by anyone.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is a nested class? Why can it be useful?&lt;/span&gt;&lt;br /&gt;A nested class is a class enclosed within the scope of another class. For example:&lt;br /&gt;// Example 1: Nested class&lt;br /&gt;//&lt;br /&gt;class OuterClass&lt;br /&gt;{&lt;br /&gt;class NestedClass&lt;br /&gt;{&lt;br /&gt;// ...&lt;br /&gt;};&lt;br /&gt;// ...&lt;br /&gt;};&lt;br /&gt;Nested classes are useful for organizing code and controlling access and dependencies. &lt;br /&gt;Nested classes obey access rules just like other parts of a class do; so, in Example 1, if NestedClass is public then any code can name it as OuterClass::NestedClass. Often nested classes contain private implementation details, and are therefore made private; in Example 1, if NestedClass is private, then only OuterClass&#39;s members and friends can use NestedClass. When you instantiate as outer class, it won&#39;t instantiate inside class.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is a local class? Why can it be useful?&lt;/span&gt;&lt;br /&gt;local class is a class defined within the scope of a function -- any function, whether a member function or a free function. For example:&lt;br /&gt;// Example 2: Local class&lt;br /&gt;//&lt;br /&gt;int f()&lt;br /&gt;{&lt;br /&gt;class LocalClass&lt;br /&gt;{&lt;br /&gt;// ...&lt;br /&gt;};&lt;br /&gt;// ...&lt;br /&gt;};&lt;br /&gt;Like nested classes, local classes can be a useful tool for managing code dependencies. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?&lt;/span&gt;&lt;br /&gt;No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;How can you tell what shell you are running on UNIX system?&lt;/span&gt;&lt;br /&gt;You can do the Echo $RANDOM. It will return a undefined variable if you are from the &lt;br /&gt;C-Shell, just a return prompt if you are from the Bourne shell, and a 5 digit random numbers if you are from the Korn shell. You could also do a ps -l and look for the shell with the highest PID.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is Boyce Codd Normal form?&lt;/span&gt;&lt;br /&gt;A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional dependencies in F+ of the form a-&gt;b, where a and b is a subset of R, at least one of the following holds: &lt;br /&gt;• a-&gt;b is a trivial functional dependency (b is a subset of a) &lt;br /&gt;• a is a superkey for schema R &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;Could you tell something about the Unix System Kernel?&lt;/span&gt;&lt;br /&gt;The kernel is the heart of the UNIX openrating system, it’s reponsible for controlling the computer’s resouces and scheduling user jobs so that each one gets its fair share of resources. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;What is a Make file?&lt;/span&gt;&lt;br /&gt;Make file is a utility in Unix to help compile large programs. It helps by only compiling the portion of the program that has been changed&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:red;&quot;&gt;How do you link a C++ program to C functions? &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;By using the extern &quot;C&quot; linkage specification around the C function declarations. &lt;br /&gt;Explain the scope resolution operator. &lt;br /&gt;Design and implement a String class that satisfies the following:&lt;br /&gt;Supports embedded nulls &lt;br /&gt;Provide the following methods (at least) &lt;br /&gt;Constructor &lt;br /&gt;Destructor &lt;br /&gt;Copy constructor &lt;br /&gt;Assignment operator &lt;br /&gt;Addition operator (concatenation) &lt;br /&gt;Return character at location &lt;br /&gt;Return substring at location &lt;br /&gt;Find substring &lt;br /&gt;Provide versions of methods for String and for char* arguments &lt;br /&gt;Suppose that data is an array of 1000 integers. &lt;br /&gt;&lt;br /&gt;Write a single function call that will sort the 100 elements data [222] through data [321].&lt;br /&gt;Answer: quicksort ((data + 222), 100);</description><link>http://dotnetlibrary.blogspot.com/2007/02/c-faq.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>32</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-117015688559728002</guid><pubDate>Tue, 30 Jan 2007 11:33:00 +0000</pubDate><atom:updated>2007-01-30T03:36:40.063-08:00</atom:updated><title>Programing demo - .NET using Partial Types for better code</title><description>&lt;div align=&#39;center&#39;&gt;&lt;object width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/oaw8K8GNhAI&quot;&gt;&lt;/param&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/oaw8K8GNhAI&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;</description><link>http://dotnetlibrary.blogspot.com/2007/01/programing-demo-net-using-partial.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-117015664652124266</guid><pubDate>Tue, 30 Jan 2007 11:28:00 +0000</pubDate><atom:updated>2007-01-30T03:37:16.803-08:00</atom:updated><title>&quot;Dot Net Rocks&quot; Part of 9-Nov-06 HDNUG Meeting</title><description>&lt;div align=&#39;center&#39;&gt;&lt;object height=&quot;350&quot; width=&quot;425&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/9MjXMzhAJEU&quot;&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;embed src=&quot;http://www.youtube.com/v/9MjXMzhAJEU&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;</description><link>http://dotnetlibrary.blogspot.com/2007/01/dot-net-rocks-part-of-9-nov-06-hdnug.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116419824123543313</guid><pubDate>Wed, 22 Nov 2006 11:46:00 +0000</pubDate><atom:updated>2006-11-22T04:24:09.886-08:00</atom:updated><title>Using Visual SourceSafe for ASP.NET</title><description>Walks through the complete process of managing your ASP.NET projects using Microsoft Visual SourceSafe.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Contents&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Why Source-Code Control&lt;br /&gt;Set Up Your SourceSafe Database&lt;br /&gt;Adding Your ASP.NET Solution to VSS&lt;br /&gt;Retrieving Solutions from Visual Studio .NET&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Some developers believe that source-code control is a necessary evil. Yet, source-code control is a sound business practice supporting your software development process. In this article you will be shown a real-world step-by-step approach to effectively using Microsoft® Visual SourceSafe® as your source-code control mechanism. You will be shown how to create a new SourceSafe database, how to check in and check out files, and how to create releases using labels.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Why Source-Code Control&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;From a simplistic perspective, a Software Configuration Management (SCM) product, like Visual SourceSafe (VSS), is a central library, or database, of documents that make up a project. Visual SourceSafe can store any stream of bits, such as project plans, specification documents, database objects, source code, and any other artifacts of your project. As a best practice, all project artifacts, not just source code, should be contained in a Visual SourceSafe database for easy access, sharing among team members, and most importantly, for version control.&lt;br /&gt;&lt;br /&gt;As in any library, the ability to &quot;check out&quot; a file for use is necessary. By checking out a file, a user can edit the file. Typically, only one person can check out and edit a file at a time. As a best practice, ensure that only ONE person can ever have a file checked out. In our research for this article, we reviewed some white papers that offered scenarios of Visual SourceSafe use recommending that multiple users could check out the same file. They recommended that all changes could then be merged back together. While this may appear somewhat easy to do using the tools built into VSS, in actual practice it has several drawbacks. It takes longer to check items back in, could lead to someone having to manually check conflicts in the merge process, does not generally work with binary artifacts such as databases, Microsoft® Word documents, and so on, and does not always reflect the accurate history of who updated what and when.&lt;br /&gt;&lt;br /&gt;VSS allows the administrator of the library to define its access control. Users are given access IDs and passwords, plus access rights. Access rights may be as simple as read or read/write capabilities, or as complicated as functional rights. A functional right, for example, is the ability to delete files.&lt;br /&gt;&lt;br /&gt;Knowing what has happened to each and every file (source code, project plans, requirements, and so on) through its lifecycle is a very important feature. VSS keeps a history of all activity, such as when a file was created and by whom, each revision to that file, notes or comments about that file, and other information to help you track the lifecycle of that document.&lt;br /&gt;&lt;br /&gt;The VSS features mentioned above, and many more, allow you to effectively manage the development, build, and maintenance process in a structured, well-managed approach. These are just some of the reasons why the use of VSS will help make your software development much more productive.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Set Up Your SourceSafe Database&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;Now that you have a good overview of Visual SourceSafe and understand the benefits of using it, let&#39;s learn how to get started. The first step is to identify a location for your centralized VSS database. The database is not a database in the strict sense of the word. It is simply a folder on a hard drive. This folder should be placed onto a network share where all developers can locate it. If you are a single developer, this could even be put onto your local hard drive.&lt;br /&gt;&lt;br /&gt;If you have not already done so, install the VSS Administration tools from your VSS CD. You need to choose these options through the custom install. On the CDD you will typically run the ACMBoot.exe to allow you to install the Administration tools. Under the Custom options for the install, you will need to choose &lt;strong&gt;Administrative Programs&lt;/strong&gt; and &lt;strong&gt;Create SourceSafe Database&lt;/strong&gt; options.&lt;br /&gt;&lt;br /&gt;After installing the Administrative programs, you may now go to your &lt;strong&gt;Start&lt;/strong&gt; menu. Click &lt;strong&gt;Programs Microsoft Visual SourceSafe Visual SourceSafe 6.0 Admin&lt;/strong&gt;. This will launch an interface from which you can click &lt;strong&gt;Tools Create Database...&lt;/strong&gt; . You will see a dialog box that looks like Figure 1. Type in the location where you wish to create this new SourceSafe database, such as &quot;D:\MyVSSDB&quot; or &lt;a href=&quot;file:////SharedDrive/MyVSSDB&quot;&gt;file:////SharedDrive/MyVSSDB&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss1.png&quot; border=&quot;0&quot; /&gt; &lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 1. Specify the location of a shared folder to be used for all your SourceSafe files.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;After the database is created, you will see a dialog that looks like Figure 2. This is just a warning that when this SourceSafe database is created, the Admin user that is created has no password associated with it. Be sure to assign a password to the Admin user by clicking on the Admin user and clicking &lt;strong&gt;Users Change Password...&lt;/strong&gt; from the menu.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss2.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 2. Secure your Administration tool by assigning a password to the Admin user.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;After you have created the database, you will now be in the Visual SourceSafe Administrator tool (Figure 3). This tool only allows you to connect up to one VSS database at a time. You must create all the users in this database that will be allowed to check out and check in files from this database. For each database that you create, you will need to add the appropriate users. This is a nice feature in that only the users that you set up are allowed into this database; however, if you have multiple VSS databases that you wish to grant all users access to, you will need to set up each user individually in each database.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss3.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 3. The Administrator tools allow you to create new users, create databases, lock databases, and perform other system administration functions for SourceSafe.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You should now add yourself as a new user to this database. Make sure you use your domain logon ID (without the domain name) as the user name in SourceSafe. SourceSafe will pick up your domain logon ID and attempt to use it to log on without prompting you. If you assign a Password to this VSS database, again, make sure it matches your domain password.&lt;/p&gt;&lt;p&gt;Remember the location of this new database; once you&#39;ve added users with their domain names to the database, you will need to tell everyone where it is so they can locate it when they first set up their VSS client utility.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Adding Your ASP.NET Solution to VSS&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Now that you have created a VSS database, you can add projects and project artifacts to this database. There are a couple of different methods you can use to manipulate this VSS database. You can use the VSS Explorer tool. This tool is useful for adding the &quot;other project artifacts&quot; to your database. You can also use VSS from within Visual Studio .NET. In fact, for adding new projects to VSS, it is recommended that you use Visual Studio .NET to add them. Using the Visual Studio .NET interface will add some binding information to your .SLN file so other developers can get hooked up to VSS automatically upon getting the solution from VSS&lt;/p&gt;&lt;p&gt;Assuming that you have downloaded and installed the ASP.NET Portal Starter Kit, you will now learn how to add this solution to VSS. With the solution open in Visual Studio .NET, select &lt;strong&gt;File Source Control Add Solution to Source Control...&lt;/strong&gt; from the menus as shown in Figure 4.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss4.png&quot; border=&quot;0&quot; /&gt;Figure 4. Add solutions to SourceSafe using the menus built into Visual Studio .NET.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;After selecting this menu item, you will most likely get the dialog shown in Figure 5. If you are using the isolated development mode, this just means that you will now reference all your files using normal file URLs instead of FrontPage Server Extensions. Go ahead and click the check box &lt;strong&gt;Don&#39;t&#39; show this dialog box again (Always allow addition of Web projects using File Share access to source control)&lt;/strong&gt;, and then click &lt;strong&gt;Continue&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss5.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 5. Switching from FrontPage Server extensions to using file share access&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You will now be prompted for your logon ID and password (see Figure 6) that you created when you set up your VSS database. Type in JohnD (or whatever you used) and any password that you set up. You will then need to click &lt;strong&gt;Browse...&lt;/strong&gt; to locate the specific folder where you created your VSS database. When you are finished, click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss6.1.gif&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 6.VSS logon&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Visual SourceSafe will now prompt you for the project name to create in the database. This first dialog, Figure 7, &quot;Add to SourceSafe Project,&quot; will refer to the Visual Studio .NET project where the solution file resides. Enter the name for this project such as, ASP.NET Portal Starter Kit (VBVS).&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss7.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 7. Give your project a name that will make it easy for you and other developers to locate later on.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;VSS will prompt you for each and every Visual Studio .NET project in your solution. VSS will automatically add each Visual Studio .NET project name into the textbox in the Add to SourceSafe Project dialog box as shown in Figure 8. In this case, the second prompt will be PortalVBVS. Be sure to click the folder, &quot;ASP.NET Portal Starter Kit (VBVS)&quot; to place this project under this solution.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss8.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 8. Add each new project to VSS individually.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;VSS will warn you that the solution file is located in the same folder as the project. This is exactly what you want to do, so go ahead and click the check box and continue on. You may or may not get the dialog shown in Figure 9. If you do, go ahead and check the check box and click &lt;strong&gt;OK&lt;/strong&gt;. This just means that you are aware you have other items in the folder that are not a part of the project file and therefore will need to be added manually through the VSS Explorer tool. This might include documents or .SQL files that are in your folder but are now specified in the project file.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss9.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 9. If you have more files or folders that are not referenced in your project file, you will be informed of this by VSS.&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;Now that your solution and your projects have been placed under SourceSafe control you will see that Visual Studio .NET now uses special icons to show whether the file is locked or checked in as shown in Figure 10. Visual Studio .NET will display a lock icon next to each file under source-code control. You will see a check mark next to any file checked out to you, and a circle icon when a file is checked out by another user.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss10.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 11. The Visual SourceSafe Explorer allows you to view the complete project and all of the files that have been placed under source-code control.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Retrieving Solutions from Visual Studio .NET&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Once your project lead has created the initial solution for the application you are building, you will want other developers to be able to retrieve this solution and set it up on their computers. You do not want each developer to have to recreate the virtual directory on their computer and ensure that all of the files get into the proper locations. Luckily, VSS and Visual Studio .NET will take care of this for you.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Visual Studio .NET integrated with VSS will create the appropriate folders on your hard drive for you, create a new virtual directory, and copy the files down from VSS into the new folders for you. You should make sure you always do this process through Visual Studio .NET and not through VSS. Otherwise you will have to manually configure IIS and set references to the VSS database yourself.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;To follow the next steps, you will need to be a developer on another machine (or you need to wipe out the virtual directory you created earlier). Open a new instance of Visual Studio .NET. Click &lt;strong&gt;File Source Control Open from Source Control...&lt;/strong&gt; and you will see a dialog as shown in Figure 12. Click the PortalVBVS project in the window. Type in a different folder name in the &lt;strong&gt;Create a new project in the Folder&lt;/strong&gt; text box and click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss16.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 12. Retrieving a SourceSafe project into a new folder&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;If you choose a folder that does not exist on your drive (and it shouldn&#39;t) you will be prompted to create the folder. Click Yes All to create all folders necessary for this project.&lt;/p&gt;&lt;p&gt;Next you will be prompted for the virtual directory under which you wish to place this project, as shown in Figure 13.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss17.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 13. Assigning a virtual directory to the project&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Depending on how your project and solutions are laid out in SourceSafe, you may be prompted for the solution file to open. If so, choose the .SLN file from the dialog. With the Portal solution, the .SLN files are in their own separate folder, so SourceSafe might not prompt you.&lt;/p&gt;&lt;p&gt;Next, Visual Studio .NET will prompt you for the location in IIS where you wish to create this virtual directory. Enter the Web server name and virtual directory name and click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/vss18.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure 14. Assigning the project to a Web server&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Now Visual Studio .NET will start bringing down all of the files for this project. In the sample that is in this article, I used D:\PortalVBVS. This means the solution will be stored in this folder. All of the other files for this project are placed in whichever folder your default Web site is pointing to. This folder is usually c:\inetpub\wwwroot. The project is now set up on this other developer&#39;s machine and is ready to be used. They can simply select the start page for the site and press F5 to run the application. They can now start checking out files and work on them, and check them back in—all from within Visual Studio .NET.&lt;/p&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/using-visual-sourcesafe-for-aspnet.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116408713979856437</guid><pubDate>Tue, 21 Nov 2006 04:45:00 +0000</pubDate><atom:updated>2006-11-20T21:33:04.123-08:00</atom:updated><title>Naming Conventions for C# / VB.NET Projects</title><description>This document explains the naming conventions that should be used with .NET projects.&lt;br /&gt;&lt;br /&gt;A consistent naming pattern is one of the most important elements of predictability and discoverability in a managed class library. Widespread use and understanding of these naming guidelines should eliminate unclear code and make it easier for developers to understand shared code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Pascal case&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;The first letter in the identifier and the first letter of each subsequent concatenated word are capitalized.&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;B&lt;/span&gt;ack&lt;span style=&quot;color:#ff0000;&quot;&gt;C&lt;/span&gt;olor, &lt;span style=&quot;color:#ff0000;&quot;&gt;D&lt;/span&gt;ata&lt;span style=&quot;color:#ff0000;&quot;&gt;S&lt;/span&gt;et&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Camel case&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalized.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;n&lt;/span&gt;umber&lt;span style=&quot;color:#ff0000;&quot;&gt;O&lt;/span&gt;f&lt;span style=&quot;color:#ff0000;&quot;&gt;D&lt;/span&gt;ays, &lt;span style=&quot;color:#ff0000;&quot;&gt;i&lt;/span&gt;s&lt;span style=&quot;color:#ff0000;&quot;&gt;V&lt;/span&gt;alid&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Naming Guidelines&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;1). Private Variables (Fields in C#) Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Prefix private variables with a &quot;_&quot; and Hungarian-style notation.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Case guidelines&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;Use camel case as a general rule, or uppercase for very small words&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;_s&lt;/span&gt;tr&lt;span style=&quot;color:#ff0000;&quot;&gt;F&lt;/span&gt;irst&lt;span style=&quot;color:#ff0000;&quot;&gt;N&lt;/span&gt;ame, &lt;span style=&quot;color:#ff0000;&quot;&gt;_d&lt;/span&gt;set&lt;span style=&quot;color:#ff0000;&quot;&gt;E&lt;/span&gt;mployees&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;// Field&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;private OleDbConnection &lt;span style=&quot;color:#ff0000;&quot;&gt;_&lt;/span&gt;connection;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;// Property&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public OleDbConnection Connection&lt;br /&gt;{&lt;br /&gt;get { return &lt;span style=&quot;color:#ff0000;&quot;&gt;_&lt;/span&gt;connection; }&lt;br /&gt;set { &lt;span style=&quot;color:#ff0000;&quot;&gt;_c&lt;/span&gt;onnection = value;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;2). Local Variables Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Prefix private or local variables with Hungarian-style notation.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Case guidelines&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;Use camel case as a general rule, or uppercase for very small words&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;strFirstName, dsetEmployees&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;3). Namespace Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design as follows:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CompanyName.TechnologyName[.Feature][.Design]&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Prefixing namespace names with a company name or other well-established brand avoids the possibility of two published namespaces having the same name. Use a stable, recognized technology name at the second level of a hierarchical name.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;Akadia.Traffic&lt;/span&gt;, System.Web.UI, System.Windows.Forms&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;Case guidelines&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Use Pascal case as a general rule, or uppercase for very small words.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;System.Windows.Forms, System.Web.UI&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;4). Class Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use a noun or noun phrase to name a class. Do not use a type prefix, such as C for class, on a class name.Do not use the underscore character (_).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Case guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use Pascal case. Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;FileStream, Button&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;5). Interface Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Prefix interface names with the letter &quot;I&quot;, to indicate that the type is an interface.Do not use the underscore character (_).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Case guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use Pascal case. Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;IServiceProvider, IFormatable&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;6). Parameter Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;Use descriptive parameter names. Parameter names should be descriptive enough that the name of the parameter and its type can be used to determine its meaning in most scenarios. To distinguish parameters from other variables the prefix &lt;strong&gt;&quot;p&quot;&lt;/strong&gt; should be used.&lt;br /&gt;&lt;br /&gt;Do not prefix parameter names with Hungarian type notation.&lt;br /&gt;&lt;br /&gt;Do not use a prefix for parameter names of an event handler and exceptions.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Case guidelines&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;Use camel case. Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;p&lt;/span&gt;TypeName, &lt;span style=&quot;color:#ff0000;&quot;&gt;p&lt;/span&gt;NumberOfItems&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;7). Method Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use verbs or verb phrases to name methods.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Case guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use Pascal case. Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;R&lt;/span&gt;emove&lt;span style=&quot;color:#ff0000;&quot;&gt;A&lt;/span&gt;ll(), &lt;span style=&quot;color:#ff0000;&quot;&gt;G&lt;/span&gt;et&lt;span style=&quot;color:#ff0000;&quot;&gt;C&lt;/span&gt;har&lt;span style=&quot;color:#ff0000;&quot;&gt;A&lt;/span&gt;t()&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;8). Property / Enumerations Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use a noun or noun phrase to name properties.Do not use Hungarian notation.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Case guidelines&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;Use Pascal case. Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;B&lt;/span&gt;ack&lt;span style=&quot;color:#ff0000;&quot;&gt;C&lt;/span&gt;olor&lt;/span&gt;, &lt;span style=&quot;color:#ff0000;&quot;&gt;N&lt;/span&gt;umber&lt;span style=&quot;color:#ff0000;&quot;&gt;O&lt;/span&gt;f&lt;span style=&quot;color:#ff0000;&quot;&gt;I&lt;/span&gt;tems&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;9). Event Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use an EventHandler suffix on event handler names.&lt;br /&gt;&lt;br /&gt;Specify two parameters named sender and e. The sender parameter represents the object that raised the event. The sender parameter is always of type object, even if it is possible to use a more specific type. The state associated with the event is encapsulated in an instance of an event class named &lt;strong&gt;&quot;e&quot;&lt;/strong&gt;. Use an appropriate and specific event class for the e parameter type.&lt;br /&gt;Name an event argument class with the EventArgs suffix.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Case guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use Pascal case. Example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public delegate void MouseEventHandler(object sender, MouseEventArgs e);&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;9). Exception Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Naming guidelines&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Event handlers in Visual Studio .NET tend to use an &quot;e&quot; parameter for the event parameter to the call. To ensure we avoid a conflict, we will use &quot;ex&quot; as a standard variable name for an Exception object.&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;catch (Exception &lt;span style=&quot;color:#ff0000;&quot;&gt;ex&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;// Handle Exception&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;10). Constant Naming Guidelines&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The names of variables declared class constants should be all uppercase with words separated by underscores. It is recommended to use a grouping naming schema.&lt;br /&gt;&lt;br /&gt;Example (for group AP_WIN):&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;AP_WIN_MIN_WIDTH, AP_WIN_MAX_WIDTH, AP_WIN_MIN_HIGHT, AP_WIN_MAX_HIGHT&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;11). C# Primitive Type Notation&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;table border=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;sbyte&lt;/td&gt;&lt;td&gt;sy&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;short&lt;/td&gt;&lt;td&gt;s&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;int&lt;/td&gt;&lt;td&gt;i&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;long&lt;/td&gt;&lt;td&gt;l&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;byte&lt;/td&gt;&lt;td&gt;y&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ushort&lt;/td&gt;&lt;td&gt;us&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;uint&lt;/td&gt;&lt;td&gt;ui&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ulong&lt;/td&gt;&lt;td&gt;ul&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;float&lt;/td&gt;&lt;td&gt;f&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;double&lt;/td&gt;&lt;td&gt;d&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;decimal&lt;/td&gt;&lt;td&gt;dec&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;bool&lt;/td&gt;&lt;td&gt;b&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;char&lt;/td&gt;&lt;td&gt;c&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;12). Visual Control Type Notation&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;table border=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Assembly&lt;/td&gt;&lt;td&gt;asm&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Boolean&lt;/td&gt;&lt;td&gt;bln&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Button&lt;/td&gt;&lt;td&gt;btn&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Char&lt;/td&gt;&lt;td&gt;ch&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;CheckBox&lt;/td&gt;&lt;td&gt;cbx&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ComboBox&lt;/td&gt;&lt;td&gt;cmb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Container&lt;/td&gt;&lt;td&gt;ctr&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataColumn&lt;/td&gt;&lt;td&gt;dcol&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataGrid&lt;/td&gt;&lt;td&gt;dgrid&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataGridDateTimePickerColumn&lt;/td&gt;&lt;td&gt;dgdtpc&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataGridTableStyle&lt;/td&gt;&lt;td&gt;dgts&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataGridTextBoxColumn&lt;/td&gt;&lt;td&gt;dgtbc&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataReader&lt;/td&gt;&lt;td&gt;dreader&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataRow&lt;/td&gt;&lt;td&gt;drow&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataSet&lt;/td&gt;&lt;td&gt;dset&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataTable&lt;/td&gt;&lt;td&gt;dtable&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DateTime&lt;/td&gt;&lt;td&gt;date&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Dialog&lt;/td&gt;&lt;td&gt;dialog&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DialogResult&lt;/td&gt;&lt;td&gt;dr&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Double&lt;/td&gt;&lt;td&gt;dbl&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Exception&lt;/td&gt;&lt;td&gt;ex&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;GroupBox&lt;/td&gt;&lt;td&gt;gbx&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;HashTable&lt;/td&gt;&lt;td&gt;htbl&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ImageList&lt;/td&gt;&lt;td&gt;iml&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Integer&lt;/td&gt;&lt;td&gt;int&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Label&lt;/td&gt;&lt;td&gt;lbl&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ListBox&lt;/td&gt;&lt;td&gt;lbx&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ListView&lt;/td&gt;&lt;td&gt;lv&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;MarshallByRefObject&lt;/td&gt;&lt;td&gt;rmt&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Mainmenu&lt;/td&gt;&lt;td&gt;mm&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;MenuItem&lt;/td&gt;&lt;td&gt;mi&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;MDI-Frame&lt;/td&gt;&lt;td&gt;frame&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;MDI-Sheet&lt;/td&gt;&lt;td&gt;sheet&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NumericUpDown&lt;/td&gt;&lt;td&gt;nud&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Panel&lt;/td&gt;&lt;td&gt;pnl&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;PictureBox&lt;/td&gt;&lt;td&gt;pbx&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;RadioButton&lt;/td&gt;&lt;td&gt;rbtn&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SDI-Form&lt;/td&gt;&lt;td&gt;form&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SqlCommand&lt;/td&gt;&lt;td&gt;sqlcom&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SqlCommandBuilder&lt;/td&gt;&lt;td&gt;sqlcomb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SqlConnection&lt;/td&gt;&lt;td&gt;sqlcon&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SqlDataAdapter&lt;/td&gt;&lt;td&gt;sqlda&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;StatusBar&lt;/td&gt;&lt;td&gt;stb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;String&lt;/td&gt;&lt;td&gt;str&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;StringBuilder&lt;/td&gt;&lt;td&gt;strb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;TabControl&lt;/td&gt;&lt;td&gt;tabctrl&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;TabPage&lt;/td&gt;&lt;td&gt;tabpage&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;TextBox&lt;/td&gt;&lt;td&gt;tbx&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ToolBar&lt;/td&gt;&lt;td&gt;tbr&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ToolBarButton&lt;/td&gt;&lt;td&gt;tbb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Timer&lt;/td&gt;&lt;td&gt;tmr&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;UserControl&lt;/td&gt;&lt;td&gt;usr&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;WindowsPrincipal&lt;/td&gt;&lt;td&gt;wpl&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/naming-conventions-for-c-vbnet.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116376225823912568</guid><pubDate>Fri, 17 Nov 2006 11:08:00 +0000</pubDate><atom:updated>2006-11-17T03:19:44.376-08:00</atom:updated><title>Read Assembly Information Using Reflection</title><description>Reflection is ability to find information about types contained in an assembly at run time. Prior to .NET languages like C++ provided such ability in a limited sense. .NET provides a whole new set of APIs to introspect assemblies and objects. All the APIs related to reflection are located under System.Reflection namespace. .NET reflection is a powerful mechanism which not only allows you to inspect type information but also allows you to invoke methods on those types at runtime. Certain reflection APIs also allow creating of assembly in memory dynamically and use it in your code. In this article we will examine the basic and most commonly used features of reflection. Reflection APIs can be used to develop applications like class browsers, add-ons for development IDEs and inelegant editors.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Getting started&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The first thing you should do while using reflection classes is to include System.Reflection namespace.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;using System.Reflection;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Loading an assembly&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Before obtaining any information about types contained in an assembly we must first load the assembly.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Assembly myassembly = Assembly.LoadFrom(&quot;employee.dll&quot;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This statement loads an assembly called employee.dll. You can substitute your own path here. Assembly class has a static method called LoadFrom that loads the specified assembly in memory. The method returns an instance of assembly class itself.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;obtaining details about types from the assembly&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The next step is to obtain a list of various types contained in the assembly.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Types mytypes[] = myassembly.GetTypes();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Type mytype=myassembly.GetType(&quot;Company.Employee&quot;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are two methods to get type information . The method GetTypes returns an array of System.Type objects. The method GetType returns a type object having details of specified object. Note that in our example Company is the namespace. In case your assembly do not contain any namespace you will simply write the type name.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Obtaining type details&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Type class has following properties that gives details about the type under consideration :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;  Name : Gives name of the type&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  FullName : Give fully qualified name of the type&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  Namespace : Gives namespace name&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  IsClass&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  IsInterface&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  IsAbstract&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  IsCOMObject : Indicates if the type is a COM object&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  IsEnum&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  IsSealed&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;  IsPublic&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;All the property names are self-explanatory and need no separate explanation.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;obtaining details about methods, properties and fields&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Each type may have fields (member variables), properties and methods. The details about each of these types are obtained by following methods of the Type object.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;      GetMembers() : Gives array of MemberInfo objects    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      GetFields() : Gives array of FieldInfo objects    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      GetProperties() : Gives array of PropertyInfo objects    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      GetMethods() : Gives array of MethodInfo objects&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Note that you can also get information about specific method, property or field using GetMethod(&quot;mymethod&quot;), GetProperty(&quot;myprop&quot;) or GetField(&quot;myfield&quot;) methods.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;MethodInfo[] mymethods= mytype.GetMethods();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;MethodInfo mymethod = mytype.GetMethod(&quot;GetSalary&quot;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Following paragraphs list commonly used properties and methods of above objects. The property and method names are self explanatory.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Properties and methods of MethodInfo Object&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;      Name    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      IsPrivate    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      IsPublic    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      IsStatic    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      IsConstructor    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      ReturnType    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      GetParameters()    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      Invoke()&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Properties and methods of PropertyInfo Object&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;      Name    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      CanRead    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      CanWrite    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      PropertyType    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      GetValue()    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      SetValue()&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Properties and methods of FieldInfo Object&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;      Name    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      FieldType    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      IsPublic    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      IsPrivate    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      IsStatic    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      GetValue()    &lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      SetValue()&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Invoking a method on a type&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We have seen how to get information about various types from an assembly. Reflection also allows us to create instances of these types and invoke methods on them. Following code fragment shows just that.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Assembly a=Assembly.LoadFrom(&quot;employee.dll&quot;); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Type t=a.GetType(&quot;Company.Employee&quot;); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;MethodInfo getsalary=t.GetMethod(&quot;DisplayMsg&quot;); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;object obj=Activator.CreateInstance(t); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;object[] p=new object[1]; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;p[0]=&quot;Hello bipin&quot;; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;getsalary.Invoke(obj,p); &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Assembly a=Assembly.LoadFrom(&quot;employee.dll&quot;); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Type t=a.GetType(&quot;Company.Employee&quot;); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;MethodInfo getsalary=t.GetMethod(&quot;GetSalary&quot;); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;object obj=Activator.CreateInstance(t); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;object[] p=new object[1]; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;p[0]=&quot;bipin&quot;; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;object retval=getsalary.Invoke(obj,BindingFlags.DefaultBinding,  null,p,null); &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Console.WriteLine(retval);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here, we first obtained type of employee class. We then created an instance of it using Activator.CreateInstance() method.  There are two forms of Invoke() method :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;      If your method is not returning any value then you may use following form Invoke ( obj , obj[])&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;      If your method is returning some value and you want to trap it use following form :    obj = Invoke ( obj , bindingflag, binder , parameters, cultureflag )&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;For both the forms you pass instance of object on which the method will be called and array of objects that contains method parameters.&lt;br /&gt;&lt;br /&gt;The second method shown here is with most commonly used values for BindingFlags, Binder and Culture.</description><link>http://dotnetlibrary.blogspot.com/2006/11/read-assembly-information-using.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116374869844083469</guid><pubDate>Fri, 17 Nov 2006 07:30:00 +0000</pubDate><atom:updated>2006-11-16T23:34:22.166-08:00</atom:updated><title>Microsoft, Wake Up and Smell Defeat!</title><description>in ipod Market :), it&#39;s just for fun only.&lt;br /&gt;&lt;br /&gt;&lt;object width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/V5ENLm0JsQw&quot;&gt;&lt;/param&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/V5ENLm0JsQw&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;/embed&gt;&lt;/object&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/microsoft-wake-up-and-smell-defeat.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116374686618716982</guid><pubDate>Fri, 17 Nov 2006 06:41:00 +0000</pubDate><atom:updated>2006-11-16T23:13:53.573-08:00</atom:updated><title>Assemblies in .NET</title><description>&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 153);&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Assemblies Overview&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Assemblies are a fundamental part of programming with the .NET Framework. An assembly performs the following functions:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     It contains code that the common language runtime executes. Microsoft intermediate language (MSIL) code in a portable executable (PE) file will not be executed if it does not have an associated assembly manifest. Note that each assembly can have only one entry point (that is, DllMain, WinMain, or Main).&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     It forms a security boundary. An assembly is the unit at which permissions are requested and granted. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     It forms a type boundary. Every type&lt;/span&gt;&#39;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;s identity includes the name of the assembly in which it resides. A type called MyType loaded in the scope of one assembly is not the same as a type called MyType loaded in the scope of another assembly.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     It forms a reference scope boundary. The assembly&lt;/span&gt;&#39;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;s manifest contains assembly metadata that is used for resolving types and satisfying resource requests. It specifies the types and resources that are exposed outside the assembly. The manifest also enumerates other assemblies on which it depends.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     It forms a version boundary. The assembly is the smallest versionable unit in the common language runtime; all types and resources in the same assembly are versioned as a unit. The assembly&lt;/span&gt;&#39;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;s manifest describes the version dependencies you specify for any dependent assemblies. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     It forms a deployment unit. When an application starts, only the assemblies that the application initially calls must be present. Other assemblies, such as localization resources or assemblies containing utility classes, can be retrieved on demand. This allows applications to be kept simple and thin when first downloaded. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     It is the unit at which side-by-side execution is supported. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;br /&gt;Assemblies can be static or dynamic. Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in portable executable (PE) files. You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.&lt;br /&gt;&lt;br /&gt;There are several ways to create assemblies. You can use development tools, such as Visual Studio .NET, that you have used in the past to create .dll or .exe files. You can use tools provided in the .NET Framework SDK to create assemblies with modules created in other development environments. You can also use common language runtime APIs, such as Reflection.Emit, to create dynamic assemblies.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Assembly Benefits&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Assemblies are designed to simplify application deployment and to solve versioning problems that can occur with component-based applications.&lt;br /&gt;&lt;br /&gt;End users and developers are familiar with versioning and deployment issues that arise from today&#39;s component-based systems. Some end users have experienced the frustration of installing a new application on their computer, only to find that an existing application has suddenly stopped working. Many developers have spent countless hours trying to keep all necessary registry entries consistent in order to activate a COM class.&lt;br /&gt;&lt;br /&gt;Many deployment problems have been solved by the use of assemblies in the .NET Framework. Because they are self- describing components that have no dependencies on registry entries, assemblies enable zero- impact application installation. They also simplify uninstalling and replicating applications.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Versioning Problems&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;An End to DLL Conflicts&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To solve versioning problems, as well as the remaining problems that lead to DLL conflicts, the runtime uses assemblies to do the following:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     Enable developers to specify version rules between different software components.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     Provide the infrastructure to enforce versioning rules.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     Provide the infrastructure to allow multiple versions of a component to be run simultaneously (called side-by-side execution).&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Assembly Names&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An assembly&lt;/span&gt;&#39;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;s name is stored in metadata and has a significant impact on the assembly&lt;/span&gt;&#39;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;s scope and use by an application. A strong-named assembly has a fully qualified name that includes the assembly&lt;/span&gt;&#39;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;s name, culture, public key, and version number. The runtime uses this information to locate the assembly and differentiate it from other assemblies with the same name. For example, a strong-named assembly called myTypes could have the following fully qualified name:&lt;br /&gt;&lt;br /&gt;&quot;myTypes, Version=1.0.1234.0, Culture=&quot;en-US&quot;, PublicKeyToken = b77a5c561934e089c&lt;br /&gt;&lt;br /&gt;In this example, the fully qualified name indicates that the myTypes assembly has a strong name with a public key token, has the culture value for US English, and has a version number of 1.0.1234.0.&lt;br /&gt;&lt;br /&gt;Code that requests types in an assembly must use a fully qualified assembly name. This is called fully qualified binding. Partial binding, which specifies only an assembly name, is not permitted when referencing assemblies in the .NET Framework.&lt;br /&gt;&lt;br /&gt;All assembly references to assemblies that make up the .NET Framework also must contain a fully qualified name of the assembly. For example, to reference the System.Data .NET Framework assembly for version 1.0 would include:&lt;br /&gt;&lt;br /&gt;System.data, version=1.0.3300.0, Culture=neutral, PublicKeyToken = b77a5c561934e089&lt;br /&gt;&lt;br /&gt;Note that the version corresponds to the version number of all .NET Framework assemblies that shipped with .NET Framework version 1.0. For .NET Framework assemblies, the culture value is always neutral, and the public key is the same as shown in the above example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Assembly Contents&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In general, a static assembly can consist of four elements:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     The assembly manifest, which contains assembly metadata.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     Type metadata.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     Microsoft intermediate language (MSIL) code that implements the types.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;     A set of resources.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Only the assembly manifest is required, but either types or resources are needed to give the assembly any meaningful functionality.&lt;br /&gt;&lt;br /&gt;There are several ways to group these elements in an assembly. You can group all elements in a single physical file, which is shown in the following illustration.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://photos1.blogger.com/blogger/6079/3972/1600/assemblyOverview.gif&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/400/assemblyOverview.gif&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Assembly Location&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An assembly&#39;s location determines whether the common language runtime can locate it when referenced, and can also determine whether the assembly can be shared with other assemblies. You can deploy an assembly in the following locations:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;     The application&#39;s directory or subdirectories.&lt;/li&gt;&lt;/ul&gt;This is the most common location for deploying an assembly. The subdirectories of an application&#39;s root directory can be based on language or culture. If an assembly has information in the culture attribute, it must be in a subdirectory under the application directory with that culture&#39;s name.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;    The global assembly cache.&lt;/li&gt;&lt;/ul&gt;This is a machine-wide code cache that is installed wherever the common language runtime is installed. In most cases, if you intend to share an assembly with multiple applications, you should deploy it into the global assembly cache.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;     On an FTTP server.&lt;/li&gt;&lt;/ul&gt;An assembly deployed on an FTTP server must have a strong name; you point to the assembly in the codebase section of the application&#39;s configuration file.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Types of Assemblies&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt; &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Private&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;color: rgb(0, 0, 153);&quot;&gt; Public / Shared&lt;/li&gt;&lt;li style=&quot;color: rgb(0, 0, 153);&quot;&gt; Satellite&lt;/li&gt;&lt;/ul&gt;A &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;private assembly&lt;/span&gt; is normally used by a single application, and is stored in the application&#39;s directory.&lt;br /&gt;&lt;br /&gt;A &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;shared assembly&lt;/span&gt; is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Satellite assemblies&lt;/span&gt; are often used to deploy language-specific resources for an application. These language-specific assemblies work in side-by-side execution because the application has a separate product ID for each language and installs satellite assemblies in a language-specific subdirectory for each language.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;Public / Shared Assemblies - Installing an Assembly into the Global Assembly Cache&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;if we want to make any public / shared assemblies, it must be strong named and deployed in Global Assembly Cache (GAC). below the find the steps to add the assembly into GAC.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;Global Assembly Cache&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Each computer where the common language runtime is installed has a machine - wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.&lt;br /&gt;&lt;br /&gt;You should share assemblies by installing them into the global assembly cache only when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required. In addition, it is not necessary to install assemblies into the global assembly cache to make them accessible to COM interop or unmanaged code.&lt;br /&gt;&lt;br /&gt;  Note   There are scenarios where you explicitly do not want to install an assembly into the global assembly cache. If you place one of the assemblies that make up an application in the global assembly cache, you can no longer replicate or install the application by using the xcopy command to copy the application directory. You must move the assembly in the global assembly cache as well.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;There are several ways to deploy an assembly into the global assembly cache:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;     Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;     Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;     Use Windows Explorer to drag assemblies into the cache.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;        &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Note&lt;/span&gt;   In deployment scenarios, use Windows Installer 2.0 to install assemblies into the global assembly cache. Use Windows Explorer or the Global Assembly Cache tool only in development scenarios, because they do not provide assembly reference counting and other features provided when using the Windows Installer.&lt;br /&gt;&lt;br /&gt;Administrators often protect the WINNT directory using an access control list (ACL) to control write and execute access. Because the global assembly cache is installed in the WINNT directory, it inherits that directory&#39;s ACL. It is recommended that only users with Administrator privileges be allowed to delete files from the global assembly cache.&lt;br /&gt;&lt;br /&gt;Assemblies deployed in the global assembly cache must have a strong name. When an assembly is added to the global assembly cache, integrity checks are performed on all files that make up the assembly. The cache performs these integrity checks to ensure that an assembly has not been tampered with, for example, when a file has changed but the manifest does not reflect the change.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;Creating and Using Strong-Named Assemblies&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A strong name consists of the assembly&#39;s identity — its simple text name, version number, and culture information (if provided) — plus a public key and a digital signature. It is generated from an assembly file using the corresponding private key. (The assembly file contains the assembly manifest, which contains the names and hashes of all the files that make up the assembly.)&lt;br /&gt;&lt;br /&gt;Remember that once you give an assembly a strong name, all assemblies that reference that assembly also have to have strong names, so that the security of the strongly named assembly is not compromised.&lt;br /&gt;&lt;br /&gt;  Note   Once an assembly is created, you cannot sign it with a strong name. You can sign an assembly with a strong name only when you create it.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Strong Name Tool (Sn.exe)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Strong Name tool helps sign assemblies with strong names. Sn.exe provides options for key management, signature generation, and signature verification.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;sn [-quiet][option [parameter(s)]]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Examples&lt;br /&gt;&lt;br /&gt;The following command creates a new, random key pair and stores it in keyPair.snk.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;sn -k keyPair.snk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;Signing an Assembly with a Strong Name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are two ways to sign an assembly with a strong name:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;     Using the Assembly Linker (Al.exe) provided by the .NET Framework SDK.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;     Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, depending on where the key file to be used is located.&lt;/li&gt;&lt;/ul&gt;You must have a cryptographic key pair to sign an assembly with a strong name.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;To create and sign an assembly with a strong name using the Assembly Linker&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   At the command prompt, type the following command:&lt;br /&gt;&lt;br /&gt;  &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;  al /out:[assembly name] [module name] /keyfile:[file name]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    In this command, assembly name is the name of the assembly to sign with a strong name, module name is the name of the code module used to create the assembly, and file name is the name of the container or file that contains the key pair.&lt;br /&gt;&lt;br /&gt;The following example signs the assembly MyAssembly.dll with a strong name using the key file sgKey.snk.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;al /out:MyAssembly.dll MyModule.netmodule /keyfile:sgKey.snk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;To sign an assembly with a strong name using attributes&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   In a code module, add the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, specifying the name of the file or container that contains the key pair to use when signing the assembly with a strong name.&lt;br /&gt;&lt;br /&gt;The following code example uses the AssemblyKeyFileAttribute with a key file called sgKey.snk.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;[Visual Basic]&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Assembly:AssemblyKeyFileAttribute(&quot;sgKey.snk&quot;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;[C#]&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;[assembly:AssemblyKeyFileAttribute(@&quot;..\..\sgKey.snk&quot;)]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can also delay sign an assembly when compiling.  After adding the file, compile the assembly once to take the changes.&lt;br /&gt;&lt;br /&gt;When signing an assembly with a strong name, the Assembly Linker (Al.exe) looks for the key file relative to the current directory and to the output directory. When using command-line compilers, you can simply copy the key to the current directory containing your code modules.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;To install a strong-named assembly into the global assembly cache&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;At the command prompt, type the following command:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;     gacutil &lt;/span&gt;     -&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;I [assembly name]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    In this command, assembly name is the name of the assembly to install in the global assembly cache.&lt;br /&gt;&lt;br /&gt;The following example installs an assembly with the file name hello.dll into the global assembly cache.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;gacutil &lt;/span&gt;     -&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;i hello.dll&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;To remove an assembly from the global assembly cache&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;At the command prompt, type the following command:&lt;br /&gt;&lt;br /&gt; &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;   gacutil &lt;/span&gt;     -&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;u [assembly name]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    In this command, assembly name is the name of the assembly to remove from the global assembly cache.&lt;br /&gt;&lt;br /&gt;The following example removes an assembly named hello.dll from the global assembly cache.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;gacutil &lt;/span&gt;     -&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;u hello&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The .NET Framework SDK also provides a Windows shell extension called the Assembly Cache Viewer (Shfusion.dll), which you can use to remove assemblies from the global assembly cache.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(204, 0, 0);&quot;&gt;To view a list of the assemblies in the global assembly cache&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;At the command prompt, type the following command:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;      gacutil &lt;/span&gt;     -&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;l &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The .NET Framework SDK also provides a Windows shell extension called the Assembly Cache Viewer (Shfusion.dll), which you can use to view the contents of global assembly cache.</description><link>http://dotnetlibrary.blogspot.com/2006/11/assemblies-in-net.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116340980406291716</guid><pubDate>Mon, 13 Nov 2006 09:21:00 +0000</pubDate><atom:updated>2006-11-13T01:23:24.236-08:00</atom:updated><title>3-D desktop</title><description>&lt;object width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/j_lxBwvf3Vk&quot;&gt;&lt;/param&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/j_lxBwvf3Vk&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;/embed&gt;&lt;/object&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/3-d-desktop.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116340817008677863</guid><pubDate>Mon, 13 Nov 2006 08:01:00 +0000</pubDate><atom:updated>2006-11-13T01:04:13.193-08:00</atom:updated><title>Using Forms Authentication with SQL Server in ASP.NET 1.1</title><description>Most of the Web applications we have to provide the authentication to check the use credentials to logon to the secured pages in the site. By default IIS provides the windows authentication which doesn&#39;t need to write any single line of code instead of some settings in IIS. We can use Forms authentication in ASP.NET to verify the user credentials in order to access the secured pages. But for Forms authentication, we have to write little bit of code, below i have added the setps to setup the forms&lt;br /&gt;authentication.&lt;br /&gt;&lt;br /&gt;Step 1. Create a Web Application with a Logon Page&lt;br /&gt;Step 2. Configure the Web Application for Forms Authentication&lt;br /&gt;Step 3. Develop Functions to Generate a Hash and Salt value&lt;br /&gt;Step 4. Create a User Account Database&lt;br /&gt;Step 5. Use ADO.NET to Store Account Details in the Database&lt;br /&gt;Step 6. Authenticate User Credentials against the Database&lt;br /&gt;Step 7. Test the ApplicationAdditional Resources&lt;br /&gt;&lt;br /&gt;Web applications that use Forms authentication often store user credentials (user names and passwords) together with associated role or group lists in MicrosoftSQL Server.&lt;br /&gt;&lt;br /&gt;This How To describes how to securely look up user names and validate passwords against SQL Server. There are two key concepts for storing user credentials securely:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Storing password digests.&lt;/strong&gt; For security reasons, passwords should not be stored in clear text or encrypted format in the database. This How To describes how to create and store a one-way hash of a user&#39;s password rather than the password itself. This approach is preferred to storing a clear text or encrypted version of the user&#39;s password, for two reasons. First, it helps to prevent an attacker who gains access to our user store from obtaining the user passwords. In addition, this approach helps you to avoid the key-management issues associated with encryption techniques.&lt;br /&gt;&lt;br /&gt;Using a salt value when creating the hash helps to slow an attacker who is attempting to perform a dictionary attack (where an attacker attempts to decipher the key used for hashing). This approach gives you additional time to detect and react to the compromise.&lt;br /&gt;&lt;strong&gt;Important&lt;/strong&gt;: The one drawback of not storing passwords in the database is that if a user forgets a password, it cannot be recovered. As a result, your application should use password hints and store them alongside the password digest within the database.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Validating user input&lt;/strong&gt;. Where user input is passed to SQL commands, for example as string literals in comparison or pattern matching statements, great care should be taken to validate the input, to ensure that the resulting commands do not contain syntax errors and also to ensure that a hacker cannot cause your application to run arbitrary SQL commands. Validating the supplied user name during a logon process is particularly vital as your application&#39;s security model is entirely dependent on being able to correctly and securely authenticate users.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 1. Create a Web Application with a Logon Page&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Start Visual Studio .NET and create a new C# ASP.NET Web application called &lt;strong&gt;FormsAuthSQL&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;Use Solution Explorer to rename WebForm1.aspx to Logon.aspx&lt;br /&gt;&lt;br /&gt;Add the controls to Logon.aspx to create a simple logon form.&lt;br /&gt;&lt;br /&gt;Your Web page should resemble the one illustrated in Figure 1.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://photos1.blogger.com/blogger/6079/3972/1600/formsauthentication.gif&quot;&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/400/formsauthentication.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; Figure 1. Logon page Web form&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 2. Configure the Web Application for Forms Authentication&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Use Solution Explorer to open Web.config. &lt;/p&gt;&lt;p&gt;Locate the &amp;#60;authentication&amp;#62; element and change the mode attribute to Forms. Add the following &amp;#60;forms&amp;#62; element as a child of the &amp;#60;authentication&amp;#62; element and set the loginUrl, name, timeout, and path attributes as follows. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;#60;authentication mode=&amp;#34;Forms&amp;#34;&amp;#62;  &lt;/p&gt;&lt;p&gt;&amp;#60;forms loginUrl=&amp;#34;logon.aspx&amp;#34; name=&amp;#34;sqlAuthCookie&amp;#34; timeout=&amp;#34;60&amp;#34;     path=&amp;#34;/&amp;#34;&amp;#62;  &lt;/p&gt;&lt;p&gt;&amp;#60;/forms&amp;#62;&lt;/p&gt;&lt;p&gt;&amp;#60;/authentication&amp;#62;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Add the following &amp;#60;authorization&amp;#62; element beneath the &amp;#60;authentication&amp;#62; element. This will allow only authenticated users to access the application. The previously established loginUrl attribute of the &amp;#60;authentication&amp;#62; element will redirect unauthenticated requests to the logon.aspx page. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;#60;authorization&amp;#62;   &lt;/p&gt;&lt;p&gt;&amp;#60;deny users=&amp;#34;?&amp;#34; /&amp;#62;  &lt;/p&gt;&lt;p&gt;&amp;#60;allow users=&amp;#34;*&amp;#34; /&amp;#62;&lt;/p&gt;&lt;p&gt;&amp;#60;/authorization&amp;#62;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 3. Develop Functions to Generate a Hash and Salt value&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;This procedure adds two utility methods to your Web application; one to generate a random salt value, and one to create a hash based on a supplied password and salt value.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To develop functions to generate a hash and salt value &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;Open Logon.aspx.cs and add the following &lt;strong&gt;using&lt;/strong&gt; statements to the top of the file beneath the existing &lt;strong&gt;using&lt;/strong&gt; statements.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;using System.Security.Cryptography;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;&lt;br /&gt;Add the following static method to the &lt;strong&gt;WebForm1&lt;/strong&gt; class to generate a random salt value and return it as a Base 64 encoded string.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;private static string CreateSalt(int size)&lt;br /&gt;{&lt;br /&gt;// Generate a cryptographic random number using the cryptographic&lt;br /&gt;// service provider&lt;br /&gt;RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();&lt;br /&gt;byte[] buff = new byte[size];&lt;br /&gt;rng.GetBytes(buff);&lt;br /&gt;// Return a Base64 string representation of the random number&lt;br /&gt;return Convert.ToBase64String(buff);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Add the following static method to generate a hash value based on a supplied password and salt value.&lt;br /&gt;&lt;br /&gt;private static string CreatePasswordHash(string pwd, string salt)&lt;br /&gt;{&lt;br /&gt;string saltAndPwd = String.Concat(pwd, salt);&lt;br /&gt;string hashedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile( saltAndPwd, &quot;SHA1&quot;);&lt;br /&gt;hashedPwd = String.Concat(hashedPwd, salt);&lt;br /&gt;return hashedPwd;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 4. Create a User Account Database&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;Run the the table Users script in SQL query analyzer to create the table.&lt;br /&gt;&lt;br /&gt;CREATE TABLE [Users] (&lt;br /&gt;[UserName] [varchar] (20) NOT NULL ,&lt;br /&gt;[PasswordHash] [varchar] (40) NOT NULL ,&lt;br /&gt;CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED&lt;br /&gt;(&lt;br /&gt;[UserName]&lt;br /&gt;) ON [PRIMARY]&lt;br /&gt;) ON [PRIMARY]&lt;br /&gt;&lt;br /&gt;-- create stored procedure to register user details&lt;br /&gt;&lt;br /&gt;CREATE PROCEDURE RegisterUser&lt;br /&gt;@userName varchar(20),&lt;br /&gt;@passwordHash varchar(40)&lt;br /&gt;AS&lt;br /&gt;INSERT INTO Users VALUES(@userName, @passwordHash)&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;-- create stored procedure to retrieve user details&lt;br /&gt;CREATE PROCEDURE LookupUser&lt;br /&gt;@userName varchar(20)&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;SELECT PasswordHash FROM UsersWHERE UserName = @userName&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 5. Use ADO.NET to Store Account Details in the Database&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;This procedure modifies the Web application code to store the supplied user name, generated password hash and salt value in the database.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;To use ADO.NET to store account details in the database &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;Return to Visual Studio .NET and double-click the Register button on the Web form to create a button click event handler. Add the following code to the method.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;int saltSize = 5;&lt;br /&gt;string salt = CreateSalt(saltSize);&lt;br /&gt;string passwordHash = CreatePasswordHash(txtPassword.Text,salt);&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;StoreAccountDetails(&lt;br /&gt;txtUserName.Text, passwordHash);&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;lblMessage.Text = ex.Message;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Add the following &lt;strong&gt;using&lt;/strong&gt; statement at the top of the file, beneath the existing &lt;strong&gt;using&lt;/strong&gt; statements.&lt;br /&gt;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;&lt;br /&gt;Add the &lt;strong&gt;StoreAccountDetails&lt;/strong&gt; utility method using the following code. This code uses ADO.NET to connect to the &lt;strong&gt;UserAccounts&lt;/strong&gt; database and stores the supplied username, password hash and salt value in the &lt;strong&gt;Users &lt;/strong&gt;table.&lt;br /&gt;&lt;br /&gt;private void StoreAccountDetails( string userName, string passwordHash )&lt;br /&gt;{&lt;br /&gt;// See &quot;How To Use DPAPI (Machine Store) from ASP.NET&quot; for information&lt;br /&gt;// about securely storing connection strings.&lt;br /&gt;&lt;br /&gt;SqlConnection conn = new SqlConnection( &quot;Server=(local);&quot; + &quot;Integrated Security=SSPI;&quot; + &quot;database=UserAccounts&quot;);&lt;br /&gt;&lt;br /&gt;SqlCommand cmd = new SqlCommand(&quot;RegisterUser&quot;, conn );&lt;br /&gt;&lt;br /&gt;cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;SqlParameter sqlParam = null;&lt;br /&gt;//Usage of Sql parameters also helps avoid SQL Injection attacks. sqlParam = cmd.Parameters.Add(&quot;@userName&quot;, SqlDbType.VarChar, 20);&lt;br /&gt;sqlParam.Value = userName;&lt;br /&gt;sqlParam = cmd.Parameters.Add(&quot;@passwordHash &quot;, SqlDbType.VarChar, 40);&lt;br /&gt;sqlParam.Value = passwordHash;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;conn.Open();&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;}&lt;br /&gt;catch( Exception ex )&lt;br /&gt;{&lt;br /&gt;// Code to check for primary key violation (duplicate account name)&lt;br /&gt;// or other database errors omitted for clarity&lt;br /&gt;throw new Exception(&quot;Exception adding account. &quot; + ex.Message);&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;conn.Close();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 6. Authenticate User Credentials Against the Database&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;This procedure develops ADO.NET code to look up the supplied user name in the database and validate the supplied password, by matching password hashes.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;To authenticate user credentials against the database &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;private bool VerifyPassword(string suppliedUserName, string suppliedPassword )&lt;br /&gt;&lt;/strong&gt;{&lt;br /&gt;bool passwordMatch = false;&lt;br /&gt;// Get the salt and pwd from the database based on the user name.&lt;br /&gt;// See &quot;How To: Use DPAPI (Machine Store) from ASP.NET,&quot; &quot;How To:&lt;br /&gt;// Use DPAPI (User Store) from Enterprise Services,&quot; and &quot;How To:&lt;br /&gt;// Create a DPAPI Library&quot; for more information about how to use&lt;br /&gt;// DPAPI to securely store connection strings.&lt;br /&gt;&lt;br /&gt;SqlConnection conn = new SqlConnection( &quot;Server=(local);&quot; + &quot;Integrated Security=SSPI;&quot; + &quot;database=UserAccounts&quot;);&lt;br /&gt;&lt;br /&gt;SqlCommand cmd = new SqlCommand( &quot;LookupUser&quot;, conn );&lt;br /&gt;cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;//Usage of Sql parameters also helps avoid SQL Injection attacks. SqlParameter sqlParam = cmd.Parameters.Add(&quot;@userName&quot;, SqlDbType.VarChar, 20);&lt;br /&gt;sqlParam.Value = suppliedUserName;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;conn.Open();&lt;br /&gt;SqlDataReader reader = cmd.ExecuteReader(); reader.Read();&lt;br /&gt;// Advance to the one and only row&lt;br /&gt;// Return output parameters from returned data stream&lt;br /&gt;string dbPasswordHash = reader.GetString(0);&lt;br /&gt;int saltSize = 5;&lt;br /&gt;string salt = dbPasswordHash.Substring(dbPasswordHash.Length - saltSize);&lt;br /&gt;reader.Close();&lt;br /&gt;// Now take the password supplied by the user&lt;br /&gt;// and generate the hash.&lt;br /&gt;string hashedPasswordAndSalt = CreatePasswordHash(suppliedPassword, salt);&lt;br /&gt;// Now verify them.&lt;br /&gt;passwordMatch = hashedPasswordAndSalt.Equals(dbPasswordHash);&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;throw new Exception(&quot;Execption verifying password. &quot; + ex.Message);&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;conn.Close();&lt;br /&gt;}&lt;br /&gt;return passwordMatch;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 7. Test the Application&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;This procedure tests the application. You will register a user, which results in the user name, password hash and salt value being added to the &lt;strong&gt;Users&lt;/strong&gt; table in the &lt;strong&gt;UserAccounts&lt;/strong&gt; database. You will then log on the same user to ensure the correct operation of the password verification routines.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To test the application&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Return to the Logon form and double-click the &lt;strong&gt;Logon&lt;/strong&gt; button to create a button click event handler.&lt;br /&gt;&lt;br /&gt;Add the following code to the &lt;strong&gt;Logon&lt;/strong&gt; button click event handler to call the &lt;strong&gt;VerifyPassword&lt;/strong&gt; method and display a message based on whether or not the supplied user name and password are valid.&lt;br /&gt;&lt;br /&gt;bool passwordVerified = false;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;passwordVerified = VerifyPassword(txtUserName.Text,txtPassword.Text);&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;lblMessage.Text = ex.Message;&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;if (passwordVerified == true )&lt;br /&gt;{&lt;br /&gt;// The user is authenticated&lt;br /&gt;// At this point, an authentication ticket is normally created&lt;br /&gt;// This can subsequently be used to generate a GenericPrincipal&lt;br /&gt;// object for .NET authorization purposes&lt;br /&gt;// For details, see &quot;How To: Use Forms authentication with&lt;br /&gt;// GenericPrincipal objects&lt;br /&gt;lblMessage.Text = &quot;Logon successful: User is authenticated&quot;;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;lblMessage.Text = &quot;Invalid username or password&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;On the Build menu, click Build Solution.&lt;br /&gt;&lt;br /&gt;In Solution Explorer, right-click logon.aspx, and then click View in Browser.&lt;br /&gt;&lt;br /&gt;Enter a user name and password, and then click Register.&lt;br /&gt;&lt;br /&gt;Use SQL Server Enterprise Manager to view the contents of the Users table. You should see a new row for the new user name together with a generated password hash.&lt;br /&gt;&lt;br /&gt;Return to the Logon Web page, re-enter the password, and then click Logon. You should see the message &quot;Logon successful: User is authenticated.&quot;&lt;br /&gt;&lt;br /&gt;Now enter an invalid password (leaving the user name the same). You should see the message &quot;Invalid username or password.&quot;&lt;/p&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/using-forms-authentication-with-sql.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116279329184256525</guid><pubDate>Mon, 06 Nov 2006 06:07:00 +0000</pubDate><atom:updated>2006-11-05T22:08:11.990-08:00</atom:updated><title>friday vs monday</title><description>&lt;object width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/-LZ99JCRdfY&quot;&gt;&lt;/param&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/-LZ99JCRdfY&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;350&quot;&gt;&lt;/embed&gt;&lt;/object&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/friday-vs-monday.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116279192734602107</guid><pubDate>Mon, 06 Nov 2006 05:44:00 +0000</pubDate><atom:updated>2006-11-05T21:45:53.163-08:00</atom:updated><title>The &quot;smiley&quot; intervention</title><description>&lt;object height=&quot;350&quot; width=&quot;425&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/NVOFmu2ZIqI&quot;&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;embed src=&quot;http://www.youtube.com/v/NVOFmu2ZIqI&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; height=&quot;350&quot; width=&quot;425&quot;&gt;&lt;/object&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/smiley-intervention.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116277322542459245</guid><pubDate>Mon, 06 Nov 2006 00:33:00 +0000</pubDate><atom:updated>2006-11-05T20:38:43.283-08:00</atom:updated><title>VB.NET and C# Code Syntax</title><description>&lt;span style=&quot;font-size:100%;&quot;&gt;&lt;span style=&quot;font-family: arial;font-size:85%;&quot; &gt;Generally if we are working on multiple projects that have to use differenet languages like VB.NET  and C#, most of the time it&#39;s very difficult to remember all the syntax changes in those languages. Here i have added the vb.net and c# syntax formats. Hope that it will be useful.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;VariableDeclaration&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Variable Declarations&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim x As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s1, s2 As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim o &amp;#39;Implicitly Object&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim obj As New Object&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Public name As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;int x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s1, s2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Object o;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Object obj = new Object&amp;#40;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;public String name;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Constants&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Const MAX_STUDENTS As Integer = 25 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Can set to a const or var; may be initialized in a constructor&lt;br /&gt;ReadOnly MIN_DIAMETER As Single = 4&amp;#46;93 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;const int MAX_STUDENTS = 25; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Can set to a const or var; may be initialized in a constructor&lt;br /&gt;readonly float MIN_DIAMETER = 4&amp;#46;93f; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Statements&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;Statements&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Response&amp;#46;Write&amp;#40;&amp;#34;foo&amp;#34;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Response&amp;#46;Write&amp;#40;&amp;#34;foo&amp;#34;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Comments&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;a name=&quot;Comments&quot;&gt;&lt;/a&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; This is a comment&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; This&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; is&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; multiline&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; comment&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// This is a comment&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;/&amp;#42;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;This&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;is&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;multiline&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;comment&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#42;/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;UseIndexedProperty&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Accessing Indexed Properties&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s, value As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s = Request&amp;#46;QueryString&amp;#40;&amp;#34;Name&amp;#34;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;value = Request&amp;#46;Cookies&amp;#40;&amp;#34;Key&amp;#34;&amp;#41;&amp;#46;Value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39;Note that default non&amp;#45;indexed properties&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39;must be explicitly named in VB.NET&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s = Request&amp;#46;QueryString[&amp;#34;Name&amp;#34;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String value = Request&amp;#46;Cookies[&amp;#34;key&amp;#34;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;DeclareIndexedProperty&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Declaring Indexed Properties&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Default Indexed Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Public Default ReadOnly Property DefaultProperty&amp;#40;Name As String&amp;#41; As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Get&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;Return CStr&amp;#40;lookuptable&amp;#40;name&amp;#41;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;End Get&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Default Indexed Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;public String this[String name] &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;get &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;        &lt;/span&gt;return &amp;#40;String&amp;#41; lookuptable[name];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;SimpleProperty&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Declaring Simple Properties&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Public Property Name As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Get&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Return &amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;End Get&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Set&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46; = Value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;End Set&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;ex:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Private _size As Integer&lt;br /&gt;&lt;br /&gt;Public Property Size&amp;#40;&amp;#41; As Integer&lt;br /&gt;  Get&lt;br /&gt;    Return _size&lt;br /&gt;  End Get&lt;br /&gt;  Set &amp;#40;ByVal Value As Integer&amp;#41;&lt;br /&gt;    If Value &amp;#60; 0 Then&lt;br /&gt;      _size = 0&lt;br /&gt;    Else&lt;br /&gt;      _size = Value&lt;br /&gt;    End If&lt;br /&gt;  End Set&lt;br /&gt;End Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;foo&amp;#46;Size &amp;#43;= 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;public String name &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;get &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;return &amp;#46;&amp;#46;&amp;#46;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;set &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46; = value;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;Enumeration&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;ex:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;private int _size;&lt;br /&gt;&lt;br /&gt;public int Size &amp;#123;&lt;br /&gt;  get &amp;#123;&lt;br /&gt;    return _size;&lt;br /&gt;  &amp;#125;&lt;br /&gt;  set &amp;#123;&lt;br /&gt;    if &amp;#40;value &amp;#60; 0&amp;#41;&lt;br /&gt;      _size = 0;&lt;br /&gt;    else&lt;br /&gt;      _size = value;&lt;br /&gt;  &amp;#125;&lt;br /&gt;&amp;#125; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;br /&gt;foo&amp;#46;Size&amp;#43;&amp;#43;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(153, 0, 0); font-weight: bold;&quot;&gt;Declare and Use an Enumeration&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Declare the Enumeration&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Public Enum MessageSize&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Small = 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Medium = 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Large = 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Enum&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Create a Field or Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Public MsgSize As MessageSize&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Assign to the property using the Enumeration values&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;MsgSize = small&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Declare the Enumeration&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;public enum MessageSize &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Small = 0,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Medium = 1,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Large = 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Create a Field or Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;public MessageSize msgsize;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Assign to the property using the Enumeration values&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;msgsize = Small;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;EnumerateCollection&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Enumerating a Collection&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim S As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;For Each S In Coll&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Next&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39;  Array or collection looping&lt;br /&gt;Dim names As String&amp;#40;&amp;#41; = &amp;#123;&amp;#34;Fred&amp;#34;, &amp;#34;Sue&amp;#34;, &amp;#34;Barney&amp;#34;&amp;#125;&lt;br /&gt;For Each s As String In names&lt;br /&gt;  Response&amp;#46;write&amp;#40;s&amp;#41;&lt;br /&gt;Next &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;foreach &amp;#40; String s in coll &amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Array or collection looping&lt;br /&gt;string[] names = &amp;#123;&amp;#34;Fred&amp;#34;, &amp;#34;Sue&amp;#34;, &amp;#34;Barney&amp;#34;&amp;#125;;&lt;br /&gt;foreach &amp;#40;string s in names&amp;#41;&lt;br /&gt;  Response&amp;#46;Write&amp;#40;s&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;Methods&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Declare and Use Methods&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Declare a void return function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Sub VoidFunction&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Declare a function that returns a value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Function StringFunction&amp;#40;&amp;#41; As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Return CStr&amp;#40;val&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Declare a function that takes and returns values&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Function ParmFunction&amp;#40;a As String, b As String&amp;#41; As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Return CStr&amp;#40;A &amp; B &amp;amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Use the Functions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;VoidFunction&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s1 As String = StringFunction&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s2 As String = ParmFunction&amp;#40;&amp;#34;Hello&amp;#34;, &amp;#34;World!&amp;#34;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Declare a void return function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;void voidfunction&amp;#40;&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Declare a function that returns a value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String stringfunction&amp;#40;&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;return &amp;#40;String&amp;#41; val;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Declare a function that takes and returns values&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String parmfunction&amp;#40;String a, String b&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;return &amp;#40;String&amp;#41; &amp;#40;a &amp;#43; b&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Use the Functions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;voidfunction&amp;#40;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s1 = stringfunction&amp;#40;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s2 = parmfunction&amp;#40;&amp;#34;Hello&amp;#34;, &amp;#34;World!&amp;#34;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;CustomAttr&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Custom Attributes&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Stand&amp;#45;alone attribute&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#60;STAThread&amp;#62;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Attribute with parameters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#60;DllImport&amp;#40;&amp;#34;ADVAPI32&amp;#46;DLL&amp;#34;&amp;#41;&amp;#62;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Attribute with named parameters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#60;DllImport&amp;#40;&amp;#34;KERNEL32&amp;#46;DLL&amp;#34;, CharSet:=CharSet&amp;#46;Auto&amp;#41;&amp;#62;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Stand&amp;#45;alone attribute&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;[STAThread]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Attribute with parameters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;[DllImport&amp;#40;&amp;#34;ADVAPI32&amp;#46;DLL&amp;#34;&amp;#41;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Attribute with named parameters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;[DllImport&amp;#40;&amp;#34;KERNEL32&amp;#46;DLL&amp;#34;, CharSet=CharSet&amp;#46;Auto&amp;#41;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;Arrays&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Arrays&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Dim a&amp;#40;2&amp;#41; As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a&amp;#40;0&amp;#41; = &amp;#34;1&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a&amp;#40;1&amp;#41; = &amp;#34;2&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a&amp;#40;2&amp;#41; = &amp;#34;3&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Dim a&amp;#40;2,2&amp;#41; As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a&amp;#40;0,0&amp;#41; = &amp;#34;1&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a&amp;#40;1,0&amp;#41; = &amp;#34;2&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a&amp;#40;2,0&amp;#41; = &amp;#34;3&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;   &lt;/span&gt;String[] a = new String[3];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a[0] = &amp;#34;1&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a[1] = &amp;#34;2&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a[2] = &amp;#34;3&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;String[][] a = new String[3][3];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a[0][0] = &amp;#34;1&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a[1][0] = &amp;#34;2&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a[2][0] = &amp;#34;3&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;Initialization&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Initialization&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s As String = &amp;#34;Hello World&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim i As Integer = 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim a&amp;#40;&amp;#41; As Double = &amp;#123; 3&amp;#46;00, 4&amp;#46;00, 5&amp;#46;00 &amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s = &amp;#34;Hello World&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;int i = 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;double[] a =&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&amp;#123; 3&amp;#46;00, 4&amp;#46;00, 5&amp;#46;00 &amp;#125;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;IFState&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;If Statements&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;If Not &amp;#40;Request&amp;#46;QueryString = Nothing&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End If&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;greeting = IIf&amp;#40;age &amp;#60; 20, &amp;#34;What&amp;#39;s up?&amp;#34;, &amp;#34;Hello&amp;#34;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;if &amp;#40;Request&amp;#46;QueryString != null&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;greeting = age &amp;#60; 20 ? &amp;#34;What&amp;#39;s up?&amp;#34; : &amp;#34;Hello&amp;#34;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;CaseState&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Case Statements&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Select Case FirstName&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Case &amp;#34;John&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Case &amp;#34;Paul&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Case &amp;#34;Ringo&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Case Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Select&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;switch &amp;#40;FirstName&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;case &amp;#34;John&amp;#34; :&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;break;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;case &amp;#34;Paul&amp;#34; :&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;break;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;case &amp;#34;Ringo&amp;#34; :&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;break;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;default:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;break;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;ForLoop&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;For Loops&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Dim I As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;For I = 0 To 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;a&amp;#40;I&amp;#41; = &amp;#34;test&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Next&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;for &amp;#40;int i=0; i&amp;#60;3; i&amp;#43;&amp;#43;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;a&amp;#40;i&amp;#41; = &amp;#34;test&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;WhileLoop&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;While Loops&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim I As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;I = 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Do While I &amp;#60; 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Response&amp;#46;write&amp;#40;I&amp;#46;ToString&amp;#40;&amp;#41;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;I &amp;#43;= 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;st1:place st=&quot;on&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Loop&lt;/span&gt;&lt;/st1:place&gt;&lt;/span&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;int i = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;while &amp;#40;i&amp;#60;3&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Response&amp;#46;Write&amp;#40;i&amp;#46;ToString&amp;#40;&amp;#41;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;i &amp;#43;= 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;Exceptions&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Exception Handling&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#39; Code that throws exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Catch E As OverflowException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#39; Catch a specific exception&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Catch E As Exception&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#39; Catch the generic exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Finally&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#39; Execute some cleanup code&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;try &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;// Code that throws exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125; catch&amp;#40;OverflowException e&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;// Catch a specific exception&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125; catch&amp;#40;Exception e&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;// Catch the generic exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125; finally &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;// Execute some cleanup code&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;StringCat&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;String Concatenation&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Using Strings&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s1, s2 As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s2 = &amp;#34;hello&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s2 &amp;= &amp;amp;#34; world&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s1 = s2 &amp; &amp;amp;#34; !!!&amp;#34;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Using StringBuilder class for performance&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s3 As New StringBuilder&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s3&amp;#46;Append&amp;#40;&amp;#34;hello&amp;#34;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s3&amp;#46;Append&amp;#40;&amp;#34; world&amp;#34;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s3&amp;#46;Append&amp;#40;&amp;#34; !!!&amp;#34;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Using Strings&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s2 = &amp;#34;hello&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s2 &amp;#43;= &amp;#34; world&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s1 = s2 &amp;#43; &amp;#34; !!!&amp;#34;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Using StringBuilder class for performance&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;StringBuilder s3 = new StringBuilder&amp;#40;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s3&amp;#46;Append&amp;#40;&amp;#34;hello&amp;#34;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s3&amp;#46;Append&amp;#40;&amp;#34; world&amp;#34;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s3&amp;#46;Append&amp;#40;&amp;#34; !!!&amp;#34;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Event Handler Delegates&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;DeclareHandler&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Sub MyButton_Click&amp;#40;Sender As Object, E As EventArgs&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;void MyButton_Click&amp;#40;Object sender, EventArgs E&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;DeclareEvent&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(153, 0, 0); font-weight: bold;&quot;&gt;Declare Events&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Create a public event&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Public Event MyEvent&amp;#40;Sender as Object, E as EventArgs&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Create a method for firing the event&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Protected Sub OnMyEvent&amp;#40;E As EventArgs&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;RaiseEvent MyEvent&amp;#40;Me, E&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Create a public event&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;public event EventHandler MyEvent;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Create a method for firing the event&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;protected void OnMyEvent&amp;#40;EventArgs e&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;MyEvent&amp;#40;this, e&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;AddRemoveHandler&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Add or Remove Event Handlers to Events&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;AddHandler Control&amp;#46;Change, AddressOf Me&amp;#46;ChangeEventHandler&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;RemoveHandler Control&amp;#46;Change, AddressOf Me&amp;#46;ChangeEventHandler&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Control&amp;#46;Change &amp;#43;= new EventHandler&amp;#40;this&amp;#46;ChangeEventHandler&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Control&amp;#46;Change &amp;#45;= new EventHandler&amp;#40;this&amp;#46;ChangeEventHandler&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;Casting&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Casting&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim obj As MyObject&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim iObj As IMyObject&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;obj = Session&amp;#40;&amp;#34;Some Value&amp;#34;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;iObj = CType&amp;#40;obj, IMyObject&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;MyObject obj = &amp;#40;MyObject&amp;#41;Session[&amp;#34;Some Value&amp;#34;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;IMyObject iObj = obj;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;Convert&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Conversion&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim i As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim s As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim d As Double&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;i = 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;s = i&amp;#46;ToString&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;d = CDbl&amp;#40;s&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; See also CDbl&amp;#40;&amp;#46;&amp;#46;&amp;#46;&amp;#41;, CStr&amp;#40;&amp;#46;&amp;#46;&amp;#46;&amp;#41;, &amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;int i = 3;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;String s = i&amp;#46;ToString&amp;#40;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;double d = Double&amp;#46;Parse&amp;#40;s&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Using Objects&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim hero As SuperHero = New SuperHero&lt;br /&gt;&amp;#39; or&lt;br /&gt;Dim hero As New SuperHero &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;With hero&lt;br /&gt;  &amp;#46;Name = &amp;#34;SpamMan&amp;#34;&lt;br /&gt;  &amp;#46;PowerLevel = 3&lt;br /&gt;End With &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;hero&amp;#46;Defend&amp;#40;&amp;#34;Laura Jones&amp;#34;&amp;#41;&lt;br /&gt;hero&amp;#46;Rest&amp;#40;&amp;#41;     &amp;#39; Calling Shared method&lt;br /&gt;&amp;#39; or&lt;br /&gt;SuperHero&amp;#46;Rest&amp;#40;&amp;#41; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim hero2 As SuperHero = hero  &amp;#39; Both reference the same object&lt;br /&gt;hero2&amp;#46;Name = &amp;#34;WormWoman&amp;#34;&lt;br /&gt;Response&amp;#46;Write&amp;#40;hero&amp;#46;Name&amp;#41;   &amp;#39; Prints WormWoman&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;hero = Nothing    &amp;#39; Free the object &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;If hero Is Nothing Then _&lt;br /&gt;  hero = New SuperHero&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim obj As Object = New SuperHero&lt;br /&gt;If TypeOf obj Is SuperHero Then _&lt;br /&gt;  Response&amp;#46;Write&amp;#40;&amp;#34;Is a SuperHero object&amp;#46;&amp;#34;&amp;#41; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Mark object for quick disposal&lt;br /&gt;Using reader As StreamReader = File&amp;#46;OpenText&amp;#40;&amp;#34;test&amp;#46;txt&amp;#34;&amp;#41;&lt;br /&gt;  Dim line As String = reader&amp;#46;ReadLine&amp;#40;&amp;#41;&lt;br /&gt;  While Not line Is Nothing&lt;br /&gt;    Response&amp;#46;Write&amp;#40;line&amp;#41;&lt;br /&gt;    line = reader&amp;#46;ReadLine&amp;#40;&amp;#41;&lt;br /&gt;  End While&lt;br /&gt;End Using &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;SuperHero hero = new SuperHero&amp;#40;&amp;#41;;&lt;br /&gt;&lt;br /&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// No &amp;#34;With&amp;#34; construct&lt;br /&gt;hero&amp;#46;Name = &amp;#34;SpamMan&amp;#34;;&lt;br /&gt;hero&amp;#46;PowerLevel = 3; &lt;br /&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;hero&amp;#46;Defend&amp;#40;&amp;#34;Laura Jones&amp;#34;&amp;#41;;&lt;br /&gt;SuperHero&amp;#46;Rest&amp;#40;&amp;#41;;   // Calling static method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;br /&gt;&lt;br /&gt;SuperHero hero2 = hero;   // Both reference the same object&lt;br /&gt;hero2&amp;#46;Name = &amp;#34;WormWoman&amp;#34;;&lt;br /&gt;Response&amp;#46;Write &amp;#40;hero&amp;#46;Name&amp;#41;;   // Prints WormWoman &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;hero = null ;   // Free the object &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;if &amp;#40;hero == null&amp;#41;&lt;br /&gt;  hero = new SuperHero&amp;#40;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Object obj = new SuperHero&amp;#40;&amp;#41;;&lt;br /&gt;if &amp;#40;obj is SuperHero&amp;#41;&lt;br /&gt; Response&amp;#46;Write &amp;#40;&amp;#34;Is a SuperHero object&amp;#46;&amp;#34;&amp;#41;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Mark object for quick disposal&lt;br /&gt;using &amp;#40;StreamReader reader = File&amp;#46;OpenText&amp;#40;&amp;#34;test&amp;#46;txt&amp;#34;&amp;#41;&amp;#41; &amp;#123;&lt;br /&gt;  string line;&lt;br /&gt;  while &amp;#40;&amp;#40;line = reader&amp;#46;ReadLine&amp;#40;&amp;#41;&amp;#41; != null&amp;#41;&lt;br /&gt;   Response&amp;#46;Write&amp;#40;line&amp;#41;;&lt;br /&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;ClassDef&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Class Definition with Inheritance&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Imports System&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Namespace MySpace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;Public Class Foo : Inherits Bar&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Dim x As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Public Sub New&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;MyBase&amp;#46;New&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;x = 4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Public Sub Add&amp;#40;x As Integer&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;      &lt;/span&gt;Me&amp;#46;x = Me&amp;#46;x &amp;#43; x&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Overrides Public Function GetNum&amp;#40;&amp;#41; As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;       &lt;/span&gt;Return x&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;End Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;End Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Namespace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; VB.NETc /out:libraryVB.NET&amp;#46;dll /t:library&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; library&amp;#46;VB.NET&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;using System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;namespace MySpace &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;public class Foo : Bar &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;int x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;public Foo&amp;#40;&amp;#41; &amp;#123; x = 4; &amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;public void Add&amp;#40;int x&amp;#41; &amp;#123; this&amp;#46;x &amp;#43;= x; &amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;override public int GetNum&amp;#40;&amp;#41; &amp;#123; return x; &amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;  &lt;/span&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// csc /out:librarycs&amp;#46;dll /t:library&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// library&amp;#46;cs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a name=&quot;InterfaceImpl&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Implementing an Interface&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Public Class MyClass : Implements IEnumerable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;Function IEnumerable_GetEnumerator&amp;#40;&amp;#41; As IEnumerator Implements IEnumerable&amp;#46;GetEnumerator&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;         &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;End Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;End Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;public class MyClass : IEnumerable &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt; &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;IEnumerator IEnumerable&amp;#46;GetEnumerator&amp;#40;&amp;#41; &amp;#123;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;         &lt;/span&gt;&amp;#46;&amp;#46;&amp;#46;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;&quot;&gt;    &lt;/span&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Structs&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Structure StudentRecord&lt;br /&gt;  Public name As String&lt;br /&gt;  Public gpa As Single&lt;br /&gt;&lt;br /&gt;  Public Sub New&amp;#40;ByVal name As String, ByVal gpa As Single&amp;#41;&lt;br /&gt;    Me&amp;#46;name = name&lt;br /&gt;    Me&amp;#46;gpa = gpa&lt;br /&gt;  End Sub&lt;br /&gt;End Structure&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Dim stu As StudentRecord = New StudentRecord&amp;#40;&amp;#34;Bob&amp;#34;, 3&amp;#46;5&amp;#41;&lt;br /&gt;Dim stu2 As StudentRecord = stu  &lt;br /&gt;&lt;br /&gt;stu2&amp;#46;name = &amp;#34;Sue&amp;#34;&lt;br /&gt;Response&amp;#46;Write&amp;#40;stu&amp;#46;name&amp;#41;    &amp;#39; Prints Bob&lt;br /&gt;Response&amp;#46;Write &amp;#40;stu2&amp;#46;name&amp;#41;  &amp;#39; Prints Sue&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;struct StudentRecord &amp;#123;&lt;br /&gt;  public string name;&lt;br /&gt;  public float gpa;&lt;br /&gt;&lt;br /&gt;  public StudentRecord&amp;#40;string name, float gpa&amp;#41; &amp;#123;&lt;br /&gt;    this&amp;#46;name = name;&lt;br /&gt;    this&amp;#46;gpa = gpa;&lt;br /&gt;  &amp;#125;&lt;br /&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;StudentRecord stu = new StudentRecord&amp;#40;&amp;#34;Bob&amp;#34;, 3&amp;#46;5f&amp;#41;;&lt;br /&gt;StudentRecord stu2 = stu; &lt;br /&gt;&lt;br /&gt;stu2&amp;#46;name = &amp;#34;Sue&amp;#34;;&lt;br /&gt;Response&amp;#46;Write &amp;#40;stu&amp;#46;name&amp;#41;;    // Prints Bob&lt;br /&gt;Response&amp;#46;Write &amp;#40;stu2&amp;#46;name&amp;#41;;   // Prints Sue&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;Constructors / Destructors&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Class SuperHero&lt;br /&gt;  Private _powerLevel As Integer&lt;br /&gt;&lt;br /&gt;  Public Sub New&amp;#40;&amp;#41;&lt;br /&gt;    _powerLevel = 0&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;  Public Sub New&amp;#40;ByVal powerLevel As Integer&amp;#41;&lt;br /&gt;    Me&amp;#46;_powerLevel = powerLevel&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;  Protected Overrides Sub Finalize&amp;#40;&amp;#41;&lt;br /&gt;   &amp;#39; Desctructor code to free unmanaged resources&lt;br /&gt;    MyBase&amp;#46;Finalize&amp;#40;&amp;#41;&lt;br /&gt;  End Sub&lt;br /&gt;End Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;class SuperHero &amp;#123;&lt;br /&gt;  private int _powerLevel;&lt;br /&gt;&lt;br /&gt;  public SuperHero&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;     _powerLevel = 0;&lt;br /&gt;  &amp;#125;&lt;br /&gt;&lt;br /&gt;  public SuperHero&amp;#40;int powerLevel&amp;#41; &amp;#123;&lt;br /&gt;    this&amp;#46;_powerLevel= powerLevel;&lt;br /&gt;  &amp;#125;&lt;br /&gt;&lt;br /&gt;  &amp;#126;SuperHero&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;    // Destructor code to free unmanaged resources&amp;#46;&lt;br /&gt;    // Implicitly creates a Finalize method&lt;br /&gt;  &amp;#125;&lt;br /&gt;&amp;#125;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(153, 0, 0);&quot;&gt;File I/O&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;VB.NET&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;Imports System&amp;#46;IO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Write out to text file&lt;br /&gt;Dim writer As StreamWriter = File&amp;#46;CreateText&amp;#40;&amp;#34;c:\myfile&amp;#46;txt&amp;#34;&amp;#41;&lt;br /&gt;writer&amp;#46;WriteLine&amp;#40;&amp;#34;Out to file&amp;#46;&amp;#34;&amp;#41;&lt;br /&gt;writer&amp;#46;Close&amp;#40;&amp;#41; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Read all lines from text file&lt;br /&gt;Dim reader As StreamReader = File&amp;#46;OpenText&amp;#40;&amp;#34;c:\myfile&amp;#46;txt&amp;#34;&amp;#41;&lt;br /&gt;Dim line As String = reader&amp;#46;ReadLine&amp;#40;&amp;#41;&lt;br /&gt;While Not line Is Nothing&lt;br /&gt;  Console&amp;#46;WriteLine&amp;#40;line&amp;#41;&lt;br /&gt;  line = reader&amp;#46;ReadLine&amp;#40;&amp;#41;&lt;br /&gt;End While&lt;br /&gt;reader&amp;#46;Close&amp;#40;&amp;#41; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Write out to binary file&lt;br /&gt;Dim str As String = &amp;#34;Text data&amp;#34;&lt;br /&gt;Dim num As Integer = 123&lt;br /&gt;Dim binWriter As New BinaryWriter&amp;#40;File&amp;#46;OpenWrite&amp;#40;&amp;#34;c:\myfile&amp;#46;dat&amp;#34;&amp;#41;&amp;#41; &lt;br /&gt;binWriter&amp;#46;Write&amp;#40;str&amp;#41; &lt;br /&gt;binWriter&amp;#46;Write&amp;#40;num&amp;#41;&lt;br /&gt;binWriter&amp;#46;Close&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&amp;#39; Read from binary file&lt;br /&gt;Dim binReader As New BinaryReader&amp;#40;File&amp;#46;OpenRead&amp;#40;&amp;#34;c:\myfile&amp;#46;dat&amp;#34;&amp;#41;&amp;#41;&lt;br /&gt;str = binReader&amp;#46;ReadString&amp;#40;&amp;#41;&lt;br /&gt;num = binReader&amp;#46;ReadInt32&amp;#40;&amp;#41;&lt;br /&gt;binReader&amp;#46;Close&amp;#40;&amp;#41;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;using System&amp;#46;IO;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Write out to text file&lt;br /&gt;StreamWriter writer = File&amp;#46;CreateText&amp;#40;&amp;#34;c:\\myfile&amp;#46;txt&amp;#34;&amp;#41;;&lt;br /&gt;writer&amp;#46;WriteLine&amp;#40;&amp;#34;Out to file&amp;#46;&amp;#34;&amp;#41;;&lt;br /&gt;writer&amp;#46;Close&amp;#40;&amp;#41;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Read all lines from text file&lt;br /&gt;StreamReader reader = File&amp;#46;OpenText&amp;#40;&amp;#34;c:\\myfile&amp;#46;txt&amp;#34;&amp;#41;;&lt;br /&gt;string line = reader&amp;#46;ReadLine&amp;#40;&amp;#41;;&lt;br /&gt;while &amp;#40;line != null&amp;#41; &amp;#123;&lt;br /&gt;  Console&amp;#46;WriteLine&amp;#40;line&amp;#41;;&lt;br /&gt;  line = reader&amp;#46;ReadLine&amp;#40;&amp;#41;;&lt;br /&gt;&amp;#125;&lt;br /&gt;reader&amp;#46;Close&amp;#40;&amp;#41;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Write out to binary file&lt;br /&gt;string str = &amp;#34;Text data&amp;#34;;&lt;br /&gt;int num = 123;&lt;br /&gt;BinaryWriter binWriter = new BinaryWriter&amp;#40;File&amp;#46;OpenWrite&amp;#40;&amp;#34;c:\\myfile&amp;#46;dat&amp;#34;&amp;#41;&amp;#41;;&lt;br /&gt;binWriter&amp;#46;Write&amp;#40;str&amp;#41;;&lt;br /&gt;binWriter&amp;#46;Write&amp;#40;num&amp;#41;;&lt;br /&gt;binWriter&amp;#46;Close&amp;#40;&amp;#41;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;// Read from binary file&lt;br /&gt;BinaryReader binReader = new BinaryReader&amp;#40;File&amp;#46;OpenRead&amp;#40;&amp;#34;c:\\myfile&amp;#46;dat&amp;#34;&amp;#41;&amp;#41;;&lt;br /&gt;str = binReader&amp;#46;ReadString&amp;#40;&amp;#41;;&lt;br /&gt;num = binReader&amp;#46;ReadInt32&amp;#40;&amp;#41;;&lt;br /&gt;binReader&amp;#46;Close&amp;#40;&amp;#41;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;&quot;&gt;&lt;/span&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: Arial;&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/vbnet-and-c-code-syntax.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116245617217195852</guid><pubDate>Thu, 02 Nov 2006 08:07:00 +0000</pubDate><atom:updated>2006-11-02T00:45:36.530-08:00</atom:updated><title>Authentication in ASP.NET</title><description>Authentication is the process of obtaining identification credentials from a user &amp;#40; such as name and password &amp;#41;, and validating those credentials against some authority.&lt;br /&gt;&lt;br /&gt;If the credentials are valid, the entity that submitted the credentials is considered an authenticated identity. Once an identity has been authenticated, the authorization process determines whether that identity has access to a given resource.&lt;br /&gt;&lt;br /&gt;An ASP.net application has two separate authentication layers. That is because ASP.net is not a standalone product. Rather it is a layer on top of IIS. All requests flow through IIS before they are handed to ASP.net. As a result, IIS can decide to deny access without the ASP.net process even knowing that someone requested a particular page. Here is an overview of the steps in the joint IIS and ASP.net authentication process.&lt;br /&gt;&lt;br /&gt;1. IIS first checks to make sure the incoming request comes from an IP address that is allowed access to the domain. If not it denies the request.&lt;br /&gt;&lt;br /&gt;2. Next IIS performs its own user authentication if it configured to do so. By default IIS allows anonymous access, so requests are automatically authenticated, but you can change this default on a per &amp;#150; application basis with in IIS.&lt;br /&gt;&lt;br /&gt;3. If the request is passed to ASP.net with an authenticated user, ASP.net checks to see whether impersonation is enabled. If impersonation is enabled, ASP.net acts as though it were the authenticated user. If not ASP.net acts with its own configured account.&lt;br /&gt;&lt;br /&gt;4. Finally the identity from step 3 is used to request resources from the operating system. If ASP.net authentication can obtain all the necessary resources it grants the users request otherwise it is denied. Resources can include much more than just the ASP.net page itself you can also use .Net&amp;#39;s code access security features to extend this authorization step to disk files, Registry keys and other resources.&lt;br /&gt;&lt;br /&gt;As you can see several security authorities interact when the user requests and ASP.net page. If things are not behaving the way you think they should, it can be helpful to review this list and make sure you have considered all the factors involved&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#660000;&quot;&gt;Authentication providers&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Assuming IIS passes a request to ASP.net, what happens next? The answer depends on the configuration of ASP.net itself. The ASP.net architecture includes the concept of and authentication provider a piece of code whose job is to verify credentials and decide whether a particular request should be considered authenticated. Out of the box ASP.net gives you a choice of three different authentication providers.&lt;br /&gt;&lt;br /&gt;&amp;#149; The windows Authentication provider lets you authenticates users based on their windows accounts. This provider uses IIS to perform the authentication and then passes the authenticated identity to your code. This is the default provided for ASP.net.&lt;br /&gt;&lt;br /&gt;&amp;#149; The passport authentication provider uses Microsoft&amp;#39;s passport service to authenticate users.&lt;br /&gt;&lt;br /&gt;&amp;#149; The forms authentication provider uses custom HTML forms to collect authentication information and lets you use your own logic to authenticate users. The user&amp;#39;s credentials are stored in a cookie for use during the session.&lt;br /&gt;&lt;br /&gt;Selecting an authentication provider is as simple as making an entry in the web.config file for the application. You can use one of these entries to select the corresponding built in authentication provider:&lt;br /&gt;&lt;br /&gt;&amp;#60;authentication mode=&amp;#34;windows&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;authentication mode=&amp;#34;passport&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;authentication mode=&amp;#34;forms&amp;#34;&amp;#62;&lt;br /&gt;&lt;br /&gt;ASP.net also supports custom authentication providers. This simply means that you set the authentication mode for the application to none, then write your own custom code to perform authentication. For example, you might install an ISAPI filter in IIS that compares incoming requests to list of source IP addresses, and considers requests to be authenticated if they come from an acceptable address. In that case, you would set the authentication mode to none to prevent any of the .net authentication providers from being triggered.&lt;br /&gt;&lt;br /&gt;The fig below illustrates the authorization and authentication mechanisms provided by ASP.NET and IIS.&lt;br /&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/400/Authentication.jpg&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color:#660000;&quot;&gt;Windows authentication and IIS&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;If you select windows authentication for your ASP.NET application, you also have to configure authentication within IIS. This is because IIS provides Windows authentication. IIS gives you a choice for four different authentication methods: &lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Anonymous, basic digest, and windows integrated&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If you select anonymous authentication, IIS doesn&amp;#39;t perform any authentication, Any one is allowed to access the ASP.NET application.&lt;/p&gt;&lt;p&gt;If you select basic authentication, users must provide a windows username and password to connect. How ever this information is sent over the network in clear text, which makes basic authentication very much insecure over the internet.&lt;/p&gt;&lt;p&gt;If you select digest authentication, users must still provide a windows user name and password to connect. However the password is hashed before it is sent across the network. Digest authentication requires that all users be running Internet Explorer 5 or later and that windows accounts to stored in active directory.&lt;/p&gt;&lt;p&gt;If you select windows integrated authentication, passwords never cross the network. Users must still have a username and password, but the application uses either the Kerberos or challenge/response protocols authenticate the user. Windows-integrated authentication requires that all users be running internet explorer 3.01 or later Kerberos is a network authentication protocol. It is designed to provide strong authentication for client/server applications by using secret-key cryptography. Kerberos is a solution to network security problems. It provides the tools of authentication and strong cryptography over the network to help to secure information in systems across entire enterprise&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color:#660000;&quot;&gt;Passport authentication&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Passport authentication lets you to use Microsoft&amp;#39;s passport service to authenticate users of your application. If your users have signed up with passport, and you configure the authentication mode of the application to the passport authentication, all authentication duties are offloaded to the passport servers.&lt;/p&gt;&lt;p&gt;Passport uses an encrypted cookie mechanism to indicate authenticated users. If users have already signed into passport when they visit your site, they&amp;#39;ll be considered authenticated by ASP.NET. Otherwise they&amp;#39;ll be redirected to the passport servers to log in. When they are successfully log in, they&amp;#39;ll be redirected back to your site&lt;/p&gt;&lt;p&gt;To use passport authentication you have to download the Passport Software Development Kit &amp;#40;SDK&amp;#41; and install it on your server. The SDK can be found at &lt;a href=&quot;http://msdn.microdoft.com/library/default.asp?url=/downloads/list/websrvpass.aps&quot;&gt;http://msdn.microdoft.com/library/default.asp?url=/downloads/list/websrvpass.aps&lt;/a&gt;&lt;/p&gt;&lt;p&gt;It includes full details of implementing passport authentication in your own applications.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;color:#660000;&quot;&gt;Forms authentication&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;Forms authentication provides you with a way to handle authentication using your own custom logic with in an ASP.NET application. The following applies if you choose forms authentication.&lt;/p&gt;&lt;p&gt;1&amp;#41; When a user requests a page for the application, ASP.NET checks for the presence of a special session cookie. If the cookie is present, ASP.NET assumes the user is authenticated and processes the request.&lt;/p&gt;&lt;p&gt;2&amp;#41; If the cookie isn&amp;#39;t present, ASP.NET redirects the user to a web form you provide&lt;/p&gt;&lt;p&gt;3&amp;#41; You can carry out whatever authentication, checks you like in your form. When the user is authenticated, you indicate this to ASP.NET by setting a property, which creates the special cookie to handle subsequent requests.&lt;br /&gt; &lt;/p&gt;&lt;p&gt; &lt;/p&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/11/authentication-in-aspnet.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116245334993699189</guid><pubDate>Thu, 02 Nov 2006 07:37:00 +0000</pubDate><atom:updated>2006-11-02T00:02:59.603-08:00</atom:updated><title>Authorization in ASP.NET</title><description>There are two closely interlinked concepts at the heart of security for distributed applications - authentication and authorization. Authentication is the process of obtaining some sort of credentials from the users and using those credentials to verify the user&amp;#39;s identity. Authorization is the process of allowing an authenticated user access to resources. Authentication is always precedes to Authorization; even if your application lets anonymous users connect and use the application, it still authenticates them as being anonymous.&lt;br /&gt;&lt;br /&gt;web.config determines the users who will be authorized to or denied from the website. The default value is &amp;#60;alow users=&amp;#34;&amp;#42;&amp;#34;/&amp;#62; which allows everyone to access the pages in the application. The value &amp;#60;deny users=&amp;#34;?&amp;#34; /&amp;#62; means to deny any anonymous &amp;#40;unauthenticated&amp;#41; user trying to access the website. However, this value can be changed.&lt;br /&gt;&lt;br /&gt;E.g., &amp;#60;deny users=&amp;#34;john&amp;#34;, &amp;#34;smith&amp;#34;, &amp;#34;Ahmed&amp;#34; /&amp;#62; means to deny the users: john, smith and Ahmed from accessing this website - it is a black list- or you can say &amp;#60;deny users=&amp;#34;&amp;#42;&amp;#34; /&amp;#62; &amp;#60;allow users=&amp;#34;john&amp;#34;, &amp;#34;smith&amp;#34;, &amp;#34;Ahmed&amp;#34; /&amp;#62; which means, deny all users except john, smith, and Ahmed.&lt;br /&gt;&lt;br /&gt;&amp;#60;!--  AUTHORIZATION&lt;br /&gt;    This section sets the authorization policies&lt;br /&gt;    of the application. You can allow or deny access&lt;br /&gt;    to application resources by user or role.&lt;br /&gt;    Wildcards: &amp;#34;&amp;#42;&amp;#34; mean everyone, &amp;#34;?&amp;#34; means anonymous&lt;br /&gt;    &amp;#40;unauthenticated&amp;#41; users.&lt;br /&gt;--&amp;#62;&lt;br /&gt;&lt;br /&gt;&amp;#60;authorization&amp;#62;&lt;br /&gt;  &amp;#60;deny users=&amp;#34;?&amp;#34; /&amp;#62; &amp;#60;!-- Allow all users --&amp;#62;&lt;br /&gt;    &amp;#60;!--  &amp;#60;allow users=&amp;#34;[comma separated list of users]&amp;#34;&lt;br /&gt;                 roles=&amp;#34;[comma separated list of roles]&amp;#34;/&amp;#62;&lt;br /&gt;        &amp;#60;deny users=&amp;#34;[comma separated list of users]&amp;#34;&lt;br /&gt;&lt;br /&gt;              roles=&amp;#34;[comma separated list of roles]&amp;#34;/&amp;#62;&lt;br /&gt;    --&amp;#62;&lt;br /&gt;&lt;br /&gt;&amp;#60;/authorization&amp;#62;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#660000;&quot;&gt;Roles&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;In some business websites, multiple employees would need access to a system in order to do specific tasks. However, each employee would have a specific role, and specific operations to do, according to the nature of his/her job or security level. E.g., an HR manager might not allowed to view the data of the seals department.&lt;br /&gt;&lt;br /&gt;ASP.NET provides the concept of roles that gives each role a different view on specific pages.&lt;br /&gt;&lt;br /&gt;&amp;#60;location path=&amp;#34;HRpages&amp;#34;&amp;#62;&lt;br /&gt;  &amp;#60;system.web&amp;#62;&lt;br /&gt;    &amp;#60;authorization&amp;#62;&lt;br /&gt;      &amp;#60;allow roles=&amp;#34;HR&amp;#34; /&amp;#62;&lt;br /&gt;      &amp;#60;deny users=&amp;#34;&amp;#42;&amp;#34; /&amp;#62;&lt;br /&gt;    &amp;#60;/authorization&amp;#62;&lt;br /&gt;   &amp;#60;/system.web&amp;#62;&lt;br /&gt;&amp;#60;/location&amp;#62;&lt;br /&gt;&lt;br /&gt;&amp;#60;location path=&amp;#34;salesPages&amp;#34;&amp;#62;&lt;br /&gt;  &amp;#60;system.web&amp;#62;&lt;br /&gt;    &amp;#60;authorization&amp;#62;&lt;br /&gt;      &amp;#60;allow roles=&amp;#34;sales&amp;#34; /&amp;#62;&lt;br /&gt;      &amp;#60;deny users=&amp;#34;&amp;#42;&amp;#34; /&amp;#62;&lt;br /&gt;    &amp;#60;/authorization&amp;#62;&lt;br /&gt;   &amp;#60;/system.web&amp;#62;&lt;br /&gt;&amp;#60;/location&amp;#62;&lt;br /&gt;&lt;br /&gt;location here means the folder name which holds the .aspx for some specific role. As the example shows, &amp;#60;location path=&amp;#34;HRpages&amp;#34;&amp;#62; means that all .aspx files under the HRpages folder are protected. &amp;#60;allow roles=&amp;#34;HR&amp;#34; /&amp;#62;&amp;#60;deny users=&amp;#34;&amp;#42;&amp;#34; /&amp;#62; mean deny every one from accessing pages under HRpages except those having the HR role.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#660000;&quot;&gt;Impersonation&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;After your application has authenticated users, you can proceed to authorize their access to resources. But there is a question to answer first: Just who is the user to whom your are grating access? It turns out that there are different answers to that question, depending on whether you implement impersonation. Impersonation is a technique that allows the ASP.NET process to act as the authenticated user, or as an arbitrary specified user.&lt;br /&gt;&lt;br /&gt;ASP.NET impersonation is controlled by entries in the applications web.config file. The default setting is &amp;#34;no impersonation&amp;#34;. You can explicitly specify that ASP.NET shouldn&amp;#39;t use impersonation by including the following code in the file&lt;br /&gt;&lt;br /&gt;&amp;#60;identity impersonate=&amp;#34;false&amp;#34;/&amp;#62;&lt;br /&gt;&lt;br /&gt;With this setting ASP.NET does not perform impersonation. It means that ASP.NET will runs with its own privileges. By default ASP.NET runs as an unprivileged account named ASPNET. You can change this by making a setting in the processModel section of the machine.config file. When you make this setting, it automatically applies to every site on the server. To user a high-privileged system account instead of a low-privileged, set the userName attribute of the processModel element to SYSTEM. Using this setting is a definite security risk, as it elevates the privileges of the ASP.NET process to a point where it can do bad things to the operating system.&lt;br /&gt;&lt;br /&gt;When you disable impersonation, all the request will run in the context of the account running ASP.NET: either the ASPNET account or the system account. This is true when you are using anonymous access or authenticating users in some fashion. After the user has been authenticated, ASP.NET uses it own identity to request access to resources.The second possible setting is to turn on impersonation.&lt;br /&gt;&lt;br /&gt;&amp;#60;identity impersonate =&amp;#34;true&amp;#34;/&amp;#62;&lt;br /&gt;&lt;br /&gt;In this case, ASP.NET takes on the identity IIS passes to it. If you are allowing anonymous access in IIS, this means ASP.NET will impersonate the IUSR_ComputerName account that IIS itself uses. If you aren&amp;#39;t allowing anonymous access,ASP.NET will take on the credentials of the authenticated user and make requests for resources as if it were that user. Thus by turning impersonation on and using a non-anonymous method of authentication in IIS, you can let users log on and use their identities within your ASP.NET application.&lt;br /&gt;&lt;br /&gt;Finally, you can specify a particular identity to use for all authenticated requests&lt;br /&gt;&lt;br /&gt;&amp;#60;identity impersonate=&amp;#34;true&amp;#34; username=&amp;#34;DOMAIN\username&amp;#34; password= &amp;#34;password&amp;#34;/&amp;#62;&lt;br /&gt;&lt;br /&gt;With this setting, all the requests are made as the specified user &amp;#40;Assuming the password it correct in the configuration file&amp;#41;. So, for example you could designate a user for a single application, and use that user&amp;#39;s identity every time someone authenticates to the application. The drawback to this technique is that you must embed the user&amp;#39;s password in the web.config file in plain text. Although ASP.NET won&amp;#39;t allow anyone to download this file, this is still a security risk if anyone can get the file by other means.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color:#660000;&quot;&gt;Best practices&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Now that you know what the choices are for ASP.NET authentication, here are some points that tell which to choose.&lt;br /&gt;&amp;#149; If there is nothing sensitive about the application, stick with no authentication in ASP.NET and anonymous authentication in IIS. That lets anyone who can reach the host computer use the application.&lt;br /&gt;&amp;#149; If you have to authenticate users, there are several choices. If all users have accounts on your network, use Windows authentication in ASP.net with one of the strong IIS authentication settings. If users don&amp;#39;t have network accounts, own custom authentication scheme is preferred, means forms authorization.&lt;br /&gt;&amp;#149; If different users must have different privileges, impersonation in ASP.net configuration files needs to be turn on.</description><link>http://dotnetlibrary.blogspot.com/2006/11/authorization-in-aspnet.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116194814160993522</guid><pubDate>Fri, 27 Oct 2006 11:10:00 +0000</pubDate><atom:updated>2006-10-27T04:54:27.430-07:00</atom:updated><title>High-Performance Web Applications using ASP.NET</title><description>&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;Developing High-Performance Web Applications with ASP.NET&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Writing a Web application with ASP.NET is unbelievably easy. So easy, many developers don&#39;t take the time to structure their applications for great performance. This article won&#39;t be the definitive guide for performance-tuning Web applications&amp;#45;an entire book could easily be devoted to that. Instead, think of this as a good place to start.&lt;br /&gt;&lt;br /&gt;You should think about the separation of your application into logical tiers. You might have heard of the term 3-tier (or n-tier) physical architecture. These are usually prescribed architecture patterns that physically divide functionality across processes and/or hardware. As the system needs to scale, more hardware can easily be added. There is, however, a performance hit associated with process and machine hopping, thus it should be avoided. So, whenever possible, run the ASP.NET pages and their associated components together in the same application. Because of the separation of code and the boundaries between tiers, using Web services or remoting will decrease performance by 20 percent or more. The data tier is a bit of a different beast since it is usually better to have dedicated hardware for your database. However, the cost of process hopping to the database is still high, thus performance on the data tier is the first place to look when optimizing your code.&lt;br /&gt;&lt;br /&gt;Before diving in to fix performance problems in your applications, make sure you profile your applications to see exactly where the problems lie. Key performance counters (such as the one that indicates the percentage of time spent performing garbage collections) are also very useful for finding out where applications are spending the majority of their time. Yet the places where time is spent are often quite unintuitive.&lt;br /&gt;&lt;br /&gt;There are two types of performance improvements described in this article: large optimizations, such as using the ASP.NET Cache, and tiny optimizations that repeat themselves. These tiny optimizations are sometimes the most interesting. You make a small change to code that gets called thousands and thousands of times. With a big optimization, you might see overall performance take a large jump. With a small one, you might shave a few milliseconds on a given request, but when compounded across the total requests per day, it can result in an enormous improvement.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(102, 0, 0); font-weight: bold;&quot;&gt;Contents : &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Performance on the Data Tier&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Return Multiple Resultsets&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Paged Data Access&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Connection Pooling&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;ASP.NET Cache API&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Per-Request Caching&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Background Processing&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Server Control View State&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Page Output Caching and Proxy Servers&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Run IIS 6.0 (If Only for Kernel Caching)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(102, 0, 0); font-weight: bold;&quot;&gt;Performance on the Data Tier&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When it comes to performance-tuning an application, there is a single litmus test you can use to prioritize work: does the code access the database? If so, how often? Note that the same test could be applied for code that uses Web services or remoting, too, but I&#39;m not covering those in this article.&lt;br /&gt;&lt;br /&gt;If you have a database request required in a particular code path and you see other areas such as string manipulations that you want to optimize first, stop and perform your litmus test. Unless you have an egregious performance problem, your time would be better utilized trying to optimize the time spent in and connected to the database, the amount of data returned, and how often you make round-trips to and from the database.&lt;br /&gt;&lt;br /&gt;With that general information established, let&#39;s look at ten tips that can help your application perform better. I&#39;ll begin with the changes that can make the biggest difference.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(102, 0, 0); font-weight: bold;&quot;&gt;Return Multiple Resultsets&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Review your database code to see if you have request paths that go to the database more than once. Each of those round-trips decreases the number of requests per second your application can serve. By returning multiple resultsets in a single database request, you can cut the total time spent communicating with the database. You&#39;ll be making your system more scalable, too, as you&#39;ll cut down on the work the database server is doing managing requests.&lt;br /&gt;&lt;br /&gt;While you can return multiple resultsets using dynamic SQL, I prefer to use stored procedures. It&#39;s arguable whether business logic should reside in a stored procedure, but I think that if logic in a stored procedure can constrain the data returned (reduce the size of the dataset, time spent on the network, and not having to filter the data in the logic tier), it&#39;s a good thing.&lt;br /&gt;&lt;br /&gt;Using a SqlCommand instance and its ExecuteReader method to populate strongly typed business classes, you can move the resultset pointer forward by calling NextResult. Returning only the data you need from the database will additionally decrease memory allocations on your server.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(102, 0, 0); font-weight: bold;&quot;&gt;Paged Data Access&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The ASP.NET DataGrid exposes a wonderful capability: data paging support. When paging is enabled in the DataGrid, a fixed number of records is shown at a time. Additionally, paging UI is also shown at the bottom of the DataGrid for navigating through the records. The paging UI allows you to navigate backwards and forwards through displayed data, displaying a fixed number of records at a time.&lt;br /&gt;&lt;br /&gt;There&#39;s one slight wrinkle. Paging with the DataGrid requires all of the data to be bound to the grid. For example, your data layer will need to return all of the data and then the DataGrid will filter all the displayed records based on the current page. If 100,000 records are returned when you&#39;re paging through the DataGrid, 99,975 records would be discarded on each request (assuming a page size of 25). As the number of records grows, the performance of the application will suffer as more and more data must be sent on each request.&lt;br /&gt;&lt;br /&gt;One good approach to writing better paging code is to use stored procedures. The total number of records returned can vary depending on the query being executed. For example, a WHERE clause can be used to constrain the data returned. The total number of records to be returned must be known in order to calculate the total pages to be displayed in the paging UI. For example, if there are 1,000,000 total records and a WHERE clause is used that filters this to 1,000 records, the paging logic needs to be aware of the total number of records to properly render the paging UI.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;Connection Pooling&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Setting up the TCP connection between your Web application and SQL Server can be an expensive operation. Developers at Microsoft have been able to take advantage of connection pooling for some time now, allowing them to reuse connections to the database. Rather than setting up a new TCP connection on each request, a new connection is set up only when one is not available in the connection pool. When the connection is closed, it is returned to the pool where it remains connected to the database, as opposed to completely tearing down that TCP connection.&lt;br /&gt;&lt;br /&gt;Of course you need to watch out for leaking connections. Always close your connections when you&#39;re finished with them. I repeat: no matter what anyone says about garbage collection within the Microsoft.NET Framework, always call Close or Dispose explicitly on your connection when you are finished with it. Do not trust the common language runtime (CLR) to clean up and close your connection for you at a predetermined time. The CLR will eventually destroy the class and force the connection closed, but you have no guarantee when the garbage collection on the object will actually happen.&lt;br /&gt;&lt;br /&gt;To use connection pooling optimally, there are a couple of rules to live by. First, open the connection, do the work, and then close the connection. It&#39;s okay to open and close the connection multiple times on each request if you have to (optimally you apply Tip 1) rather than keeping the connection open and passing it around through different methods. Second, use the same connection string (and the same thread identity if you&#39;re using integrated authentication). If you don&#39;t use the same connection string, for example customizing the connection string based on the logged-in user, you won&#39;t get the same optimization value provided by connection pooling. And if you use integrated authentication while impersonating a large set of users, your pooling will also be much less effective. The .NET CLR data performance counters can be very useful when attempting to track down any performance issues that are related to connection pooling.&lt;br /&gt;&lt;br /&gt;Whenever your application is connecting to a resource, such as a database, running in another process, you should optimize by focusing on the time spent connecting to the resource, the time spent sending or retrieving data, and the number of round-trips. Optimizing any kind of process hop in your application is the first place to start to achieve better performance. The application tier contains the logic that connects to your data layer and transforms data into meaningful class instances and business processes. For example, in Community Server, this is where you populate a Forums or Threads collection, and apply business rules such as permissions; most importantly it is where the Caching logic is performed.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;ASP.NET Cache API&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One of the very first things you should do before writing a line of application code is architect the application tier to maximize and exploit the ASP.NET Cache feature. If your components are running within an ASP.NET application, you simply need to include a reference to System.Web.dll in your application project. When you need access to the Cache, use the HttpRuntime.Cache property (the same object is also accessible through Page.Cache and HttpContext.Cache).&lt;br /&gt;&lt;br /&gt;There are several rules for caching data. First, if data can be used more than once it&#39;s a good candidate for caching. Second, if data is general rather than specific to a given request or user, it&#39;s a great candidate for the cache. If the data is user- or request-specific, but is long lived, it can still be cached, but may not be used as frequently. Third, an often overlooked rule is that sometimes you can cache too much. Generally on an x86 machine, you want to run a process with no higher than 800MB of private bytes in order to reduce the chance of an out-of-memory error. Therefore, caching should be bounded. In other words, you may be able to reuse a result of a computation, but if that computation takes 10 parameters, you might attempt to cache on 10 permutations, which will likely get you into trouble. One of the most common support calls for ASP.NET is out-of-memory errors caused by overcaching, especially of large datasets.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;Per-Request Caching&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Earlier in the article, I mentioned that small improvements to frequently traversed code paths can lead to big, overall performance gains. One of my absolute favorites of these is something I&#39;ve termed per-request caching.&lt;br /&gt;&lt;br /&gt;Whereas the Cache API is designed to cache data for a long period or until some condition is met, per-request caching simply means caching the data for the duration of the request. A particular code path is accessed frequently on each request but the data only needs to be fetched, applied, modified, or updated once. This sounds fairly theoretical, so let&#39;s consider a concrete example.&lt;br /&gt;&lt;br /&gt;In the Forums application of Community Server, each server control used on a page requires personalization data to determine which skin to use, the style sheet to use, as well as other personalization data. Some of this data can be cached for a long period of time, but some data, such as the skin to use for the controls, is fetched once on each request and reused multiple times during the execution of the request. To accomplish per-request caching, use the ASP.NET HttpContext. An instance of HttpContext is created with every request and is accessible anywhere during that request from the HttpContext.Current property. The HttpContext class has a special Items collection property; objects and data added to this Items collection are cached only for the duration of the request. Just as you can use the Cache to store frequently accessed data, you can use HttpContext.Items to store data that you&#39;ll use only on a per-request basis. The logic behind this is simple: data is added to the HttpContext.Items collection when it doesn&#39;t exist, and on subsequent lookups the data found in HttpContext.Items is simply returned.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;Background Processing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The path through your code should be as fast as possible, right? There may be times when you find yourself performing expensive tasks on each request or once every n requests. Sending out e-mails or parsing and validation of incoming data are just a few examples.&lt;br /&gt;&lt;br /&gt;When tearing apart ASP.NET Forums 1.0 and rebuilding what became Community Server, we found that the code path for adding a new post was pretty slow. Each time a post was added, the application first needed to ensure that there were no duplicate posts, then it had to parse the post using a &quot;badword&quot; filter, parse the post for emoticons, tokenize and index the post, add the post to the moderation queue when required, validate attachments, and finally, once posted, send e-mail notifications out to any subscribers. Clearly, that&#39;s a lot of work.&lt;br /&gt;&lt;br /&gt;It turns out that most of the time was spent in the indexing logic and sending e-mails. Indexing a post was a time-consuming operation, and it turned out that the built-in System.Web.Mail functionality would connect to an SMTP server and send the e-mails serially. As the number of subscribers to a particular post or topic area increased, it would take longer and longer to perform the AddPost function. Indexing e-mail didn&#39;t need to happen on each request. Ideally, we wanted to batch this work together and index 25 posts at a time or send all the e-mails every five minutes.&lt;br /&gt;&lt;br /&gt;We decided to use the same code I had used to prototype database cache invalidation for what eventually got baked into Visual Studio 2005. The Timer class, found in the System.Threading namespace, is a wonderfully useful, but less well-known class in the .NET Framework, at least for Web developers. Once created, the Timer will invoke the specified callback on a thread from the ThreadPool at a configurable interval. This means you can set up code to execute without an  incoming request to your ASP.NET application, an ideal situation for background processing. You can do work such as indexing or sending e-mail in this background process too.&lt;br /&gt;&lt;br /&gt;There are a couple of problems with this technique, though. If your application domain unloads, the timer instance will stop firing its events. In addition, since the CLR has a hard gate on the number of threads per process, you can get into a situation on a heavily loaded server where timers may not have threads to complete on and can be somewhat delayed. ASP.NET tries to minimize the chances of this happening by reserving a certain number of free threads in the process and only using a portion of the total threads for request processing. However, if you have lots of asynchronous work, this can be an issue.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;Server Control View State&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;View state is a fancy name for ASP.NET storing some state data in a hidden input field inside the generated page. When the page is posted back to the server, the server can parse, validate, and apply this view state data back to the page&#39;s tree of controls. View state is a very powerful capability since it allows state to be persisted with the client and it requires no cookies or server memory to save this state. Many ASP.NET server controls use view state to persist settings made during interactions with elements on the page, for example, saving the current page that is being displayed when paging through data.&lt;br /&gt;&lt;br /&gt;There are a number of drawbacks to the use of view state, however. First of all, it increases the total payload of the page both when served and when requested. There is also an additional overhead incurred when serializing or deserializing view state data that is posted back to the server. Lastly, view state increases the memory allocations on the server.&lt;br /&gt;&lt;br /&gt;Several server controls, the most well known of which is the DataGrid, tend to make excessive use of view state, even in cases where it is not needed. The default behavior of the ViewState property is enabled, but if you don&#39;t need it, you can turn it off at the control or page level. Within a control, you simply set the EnableViewState property to false, or you can set it globally within the page using this setting:&lt;br /&gt;&lt;br /&gt;&lt;%  @ Page EnableViewState=&quot;false&quot; %&gt;&lt;br /&gt;&lt;br /&gt;If you are not doing postbacks in a page or are always regenerating the controls on a page on each request, you should disable view state at the page level.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;Page Output Caching and Proxy Servers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ASP.NET is your presentation layer (or should be); it consists of pages, user controls, server controls (HttpHandlers and HttpModules), and the content that they generate. If you have an ASP.NET page that generates output, whether HTML, XML, images, or any other data, and you run this code on each request and it generates the same output, you have a great candidate for page output caching.&lt;br /&gt;&lt;br /&gt;By simply adding this line to the top of your page&lt;br /&gt;&lt;br /&gt;&lt;%  @ Page OutputCache VaryByParams=&quot;none&quot; Duration=&quot;60&quot; %&gt;&lt;br /&gt;&lt;br /&gt;you can effectively generate the output for this page once and reuse it multiple times for up to 60 seconds, at which point the page will re-execute and the output will once be again added to the ASP.NET Cache. This behavior can also be accomplished using some lower-level programmatic APIs, too. There are several configurable settings for output caching, such as the VaryByParams attribute just described. VaryByParams just happens to be required, but allows you to specify the HTTP GET or HTTP POST parameters to vary the cache entries. For example, default.aspx?Report=1 or default.aspx?Report=2 could be output-cached by simply setting VaryByParam=&quot;Report&quot;.&lt;br /&gt;&lt;br /&gt;Additional parameters can be named by specifying a semicolon-separated list.&lt;br /&gt;&lt;br /&gt;Many people don&#39;t realize that when the Output Cache is used, the ASP.NET page also generates a set of HTTP headers that downstream caching servers, such as those used by the Microsoft Internet Security and Acceleration Server or by Akamai. When HTTP Cache headers are set, the documents can be cached on these network resources, and client requests can be satisfied without having to go back to the origin server. Using page output caching, then, does not make your application more efficient, but it can potentially reduce the load on your server as downstream caching technology caches documents. Of course, this can only be anonymous content; once it&#39;s downstream, you won&#39;t see the requests anymore and can&#39;t perform authentication to prevent access to it.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;Run IIS 6.0 (If Only for Kernel Caching)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you&#39;re not running IIS 6.0 (Windows Server 2003), you&#39;re missing out on some great performance enhancements in the Microsoft Web server. In Tip 7, I talked about output   caching. In IIS 5.0, a request comes through IIS and then to ASP.NET. When caching is involved, an HttpModule in ASP.NET receives the request, and returns the contents from the Cache.&lt;br /&gt;&lt;br /&gt;If you&#39;re using IIS 6.0, there is a nice little feature called kernel caching that doesn&#39;t require any code changes to ASP.NET. When a request is output-cached by ASP.NET, the IIS kernel cache receives a copy of the cached data. When a request comes from the network driver, a kernel-level driver (no context switch to user mode) receives the request, and if cached, flushes the cached data to the response, and completes execution. This means that when you use kernel-mode caching with IIS and ASP.NET output caching, you&#39;ll see unbelievable performance results. At one point during the Visual Studio 2005 development of ASP.NET, I was the program manager responsible for ASP.NET performance. The developers did the magic, but I saw all the reports on a daily basis. The kernel mode caching results were always the most interesting. The common characteristic was network saturation by requests/responses and IIS running at about five percent CPU utilization. It was amazing! There are certainly other reasons for using IIS 6.0, but kernel mode caching is an obvious one.</description><link>http://dotnetlibrary.blogspot.com/2006/10/high-performance-web-applications.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116175910481018008</guid><pubDate>Wed, 25 Oct 2006 06:41:00 +0000</pubDate><atom:updated>2006-10-25T00:06:21.593-07:00</atom:updated><title>ADO.NET FAQ</title><description>&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What is ADO.Net?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ADO.Net is an object oriented framework that allows you to interact with database systems. We usually interact with database systems through SQL queries or stored procedures. ADO.Net encapsulates our queries and commands to provide a uniform access to various database management systems.&lt;br /&gt;&lt;br /&gt;ADO.Net is a successor of ADO (ActiveX Data Object). The prime features of ADO.Net are its disconnected data access architecture and XML integration.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102); font-weight: bold;&quot;&gt;What does it mean by disconnected data access architecture of ADO.Net?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ADO.Net introduces the concept of disconnected data architecture. In traditional data access components, you make a connection to the database system and then interact with it through SQL queries using the connection. The application stays connected to the DB system even when it is not using DB services.Your application automatically connects to the database server when it needs to pass some query and then disconnects immediately after getting the result back and storing it in dataset. This design of ADO.Net is called disconnected data architecture and is very much similar to the connection less services of http over the internet. It should be noted that ADO.Net also provides the connection oriented traditional data access services.&lt;br /&gt;&lt;br /&gt;Important aspect of the disconnected architecture is that it maintains the local repository of data in the dataset object. The dataset object stores the tables, their relationship and different constraints. The user performs operations like update, insert, delete to this dataset locally and finally the changed dataset is stored in actual database as a batch when needed. This greatly reduces the network traffic and results in the better performance.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What does it mean by connected data access architecture of ADO.Net?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the connected environment, it is your responsibility to open and close the database connection. You first establish the database connection, perform the interested operations to the database and when you are done, close the database connection. All the changes are done directly to the database and no local (memory) buffer is maintained.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What is a dataset?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A dataset is the local repository of the data used to store the tables and disconnected record set. When using disconnected architecture, all the updates are made locally to dataset and then the updates are performed to the database as a batch.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What is a data adapter?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A data adapter is the component that exists between the local repository (dataset) and the physical database. It contains the four different commands (SELECT, INSERT, UPDATE and DELETE). It uses these commands to fetch the data from the DB and fill into the dataset and to perform updates done in the dataset to the physical database. It is the data adapter that is responsible for opening and closing the database connection and communicates with the dataset.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What is a data reader?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The data reader is a component that reads the data from the database management system and provides it to the application. The data reader works in the connected manner; it reads a record from the DB, pass it to the application, then reads another and so on.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What is a database command?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A database command specifies which particular action you want to perform to the database. The commands are in the form of SQL (Structured Query Language).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How do different components of ADO.Net interact with each other in disconnected architecture?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Data Adapter contains in it the Command and Connection object. It uses the connection object to connect to the database, execute the containing command, fetch the result and update the DataSet.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How do different components of ADO.Net interact with each other in connected architecture?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Command object contains the Connection object. The Command object uses the containing connection (that must be opened) to execute the SQL query and if the SQL statement is SELECT, returns the DataReader object. The data reader object is the stream to the database which reads the resulting records from the DB and passes them to the application&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What&#39;s the difference between accessing data with dataset or data reader?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The dataset is generally used when you like to employ the disconnected architecture of the ADO.Net. It reads the data into the local memory buffer and perform the data operations (update, insert, delete) locally to this buffer.&lt;br /&gt;&lt;br /&gt;The data reader, on the other hand, is directly connected to the database management system. It passes all the queries to the database management system, which executes them and returns the result back to the application.&lt;br /&gt;&lt;br /&gt;Since no memory buffer is maintained by the data reader, it takes up fewer resources and performs more efficiently with small number of data operations. The dataset, on the other hand is more efficient when large number of updates are to be made to the database. All the updates are done in the local memory and are updated to the database in a batch. Since database connection remains open for the short time, the database management system does not get flooded with the incoming requests.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What are the performance considerations when using dataset?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since no memory buffer is maintained by the data reader, it takes up fewer resources and performs more efficiently with small number of data operations. The dataset, on the other hand is more efficient when large number of updates are to be made to the database. All the updates are done in the local memory and are updated to the database in a batch. Since database connection remains open for the short time, the database management system does not get flooded with the incoming requests.&lt;br /&gt;&lt;br /&gt;However, since the dataset stores the records in the local buffer in the hierarchical form, it does take up more resources and may affect the overall performance of the application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to select dataset or data reader?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The data reader is more useful when you need to work with large number of tables, database in non-uniform pattern and you need not execute the large no. of queries on few particular table.&lt;br /&gt;&lt;br /&gt;When you need to work on fewer no. of tables and most of the time you need to execute queries on these fewer tables, you should go for the dataset.&lt;br /&gt;&lt;br /&gt;It also depends on the nature of application. If multiple users are using the database and the database needs to be updated every time, you must not use the dataset. For this, .Net provides the connection oriented architecture. But in the scenarios where instant update of database is not required, dataset provides optimal performance by making the changes locally and connecting to database later to update a whole batch of data. This also reduces the network bandwidth if the database is accessed through network.&lt;br /&gt;&lt;br /&gt;Disconnected data access is suited most to read only services. On the down side, disconnected data access architecture is not designed to be used in the networked environment where multiple users are updating data simultaneously and each of them needs to be aware of current state of database at any time (e.g., Airline Reservation System).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How XML is supported in ADO.Net?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The dataset is represented in the memory as an XML document. You can fill the dataset by XML and can also get the result in the form of XML. Since XML is an international and widely accepted standard, you can read the data using the ADO.Net in the XML form and pass it to other applications using Web Service. These data consuming application need not be the essentially Dot Net based. They may be written with Java, C++ or any other programming language and running on any platform.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to get the count of records in the Database table using the DataSet?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(102, 0, 0); font-weight: bold;&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;ds.Tables(0).Rows.Count&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(102, 0, 0); font-weight: bold;&quot;&gt;C#&lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt; &lt;/span&gt;&lt;br /&gt;ds.Tables[0].Rows.Count ;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to check if the Dataset has records?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;if ds.Tables(0).Rows.Count= 0 then&lt;br /&gt;  &#39;No record&lt;br /&gt;else&lt;br /&gt;  &#39;Record Found&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;if (ds.Tables[0].Rows.Count == 0 )&lt;br /&gt;{&lt;br /&gt;  //No record&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;  //Record Found&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to retrieve value of a field in a dataset?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;ds.Tables(&quot;TableName&quot;).Rows(0)(&quot;ColumnName&quot;)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;ds.Tables[&quot;TableName&quot;].Rows[0][&quot;ColumnName&quot;];&lt;br /&gt;&lt;br /&gt;where TableName and ColumnName could be also integer (not in quotes then) to indicate you refer to the table&#39;s or column&#39;s index position. Rows(0) indicates the first and only row in DataTable&#39;s Rows collection&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to filter the data in the DataView and display it in some DataControl?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;Dim thefilter as string = &quot;fieldname=&#39;&#39; &quot;&lt;br /&gt;dbDataView.RowFilter = thefilter             &lt;br /&gt;Repeater1.DataSource = dbDataView&lt;br /&gt;Repeater.DataBind()&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;string thefilter = &quot;fieldname=&#39;&#39; &quot;;&lt;br /&gt;dbDataView.RowFilter = thefilter;                  &lt;br /&gt;Repeater1.DataSource = dbDataView;&lt;br /&gt;Repeater.DataBind();&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to truncate the data in the column?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;Protected function TruncateData( Byval strNotes as string)&lt;br /&gt;If strNotes.Length &gt; 20 then&lt;br /&gt;  Return strNotes.Substring(0,20) + &quot;...&quot;&lt;br /&gt;Else&lt;br /&gt;  return strnotes&lt;br /&gt;End function&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(102, 0, 0); font-weight: bold;&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;protected string TruncateData( string strNotes )&lt;br /&gt;{&lt;br /&gt;if (strNotes.Length &gt; 20)&lt;br /&gt;{&lt;br /&gt;  return strNotes.Substring(0,20) + &quot;...&quot;;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;  return strNotes;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to find the null fields in the datareader?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;If dbReader(&quot;fieldname&quot;).Tostring= DBnull.Value.ToString()&lt;br /&gt;  &#39;Empty field value&lt;br /&gt;Else&lt;br /&gt;  &#39;Display value&lt;br /&gt;End if&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;if (dbReader[&quot;fieldname&quot;).ToString() == DBNull.Value.ToString() )&lt;br /&gt;{&lt;br /&gt;  //Empty field value&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;  //display Value&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to query the database to get all the Table names?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELECT * FROM information_schema.tables where Table_type=&#39;BASE TABLE&#39;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;A field with bit data type value when displayed on a web page shows true/ false how to display a bit value as 1/0?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;&#39;Using DataReader&lt;br /&gt;While dr.Read()&lt;br /&gt;   Response.Write((dr(&quot;ProductName&quot;) + &quot; &quot;))&lt;br /&gt;   Response.Write((Convert.ToInt16(dr(&quot;discontinued&quot;)) + &quot; &quot;))&lt;br /&gt;End While&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;//Using DataReader&lt;br /&gt;while (dr.Read ())&lt;br /&gt;{&lt;br /&gt;  Response.Write (dr[&quot;ProductName&quot;] + &quot; &quot;);&lt;br /&gt;  Response.Write (Convert.ToInt16 ( dr[&quot;discontinued&quot;]) + &quot; &quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to get the count of items in a dataReader?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;&lt;table border0&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Dim mycn As New SqlConnection(&quot;server=localhost;uid=sa;password=;database=northwind;&quot;)&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;Dim mycmd As New SqlCommand(&quot;Select * from Products&quot;, mycn)&lt;br /&gt;mycn.Open()&lt;br /&gt;Dim dr As SqlDataReader = mycmd.ExecuteReader&lt;br /&gt;Dim i As Integer&lt;br /&gt;While dr.Read&lt;br /&gt;  i += 1&lt;br /&gt;End While&lt;br /&gt;Response.Write(&quot;Count of Records : &quot; &amp; i)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;&lt;table border=0&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;SqlConnection mycn =new SqlConnection(&quot;server=localhost;uid=sa;password=;database=northwind;&quot;);&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;SqlCommand mycmd = new SqlCommand (&quot;Select * from Products&quot;, mycn);&lt;br /&gt;mycn.Open();&lt;br /&gt;SqlDataReader dr = mycmd.ExecuteReader();&lt;br /&gt;int i=0;&lt;br /&gt;while(dr.Read())&lt;br /&gt;{&lt;br /&gt;  i+=1;&lt;br /&gt;}&lt;br /&gt;Response.Write(&quot;Count of Records : &quot; + i.ToString());&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to filter xml data and display data in the DataGrid?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;products&gt;&lt;product prodid=&quot;product1-00&quot; param1=&quot;11&quot;&gt;&lt;product prodid=&quot;product1-00&quot; param1=&quot;12&quot;&gt;&lt;product prodid=&quot;product1-01&quot; param1=&quot;13&quot;&gt;&lt;product prodid=&quot;product1-02&quot; param1=&quot;14&quot;&gt;&lt;product prodid=&quot;product2-00&quot; param1=&quot;21&quot; param2=&quot;22&quot;&gt;&lt;product prodid=&quot;product2-00&quot; param1=&quot;31&quot; param2=&quot;32&quot;&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;Dim ds As New DataSet&lt;br /&gt;ds.ReadXml(Server.MapPath(&quot;data1.xml&quot;))&lt;br /&gt;Dim dv As New DataView&lt;br /&gt;dv = ds.Tables(0).DefaultView&lt;br /&gt;dv.RowFilter = &quot;prodId=&#39;product2-00&#39;&quot;&lt;br /&gt;Me.DataGrid1.DataSource = dv&lt;br /&gt;Me.DataBind()&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;ds.ReadXml(Server.MapPath(&quot;data1.xml&quot;));&lt;br /&gt;DataView dv = new DataView();&lt;br /&gt;dv = ds.Tables[0].DefaultView;&lt;br /&gt;dv.RowFilter = &quot;prodId=&#39;product2-00&#39;&quot;;&lt;br /&gt;this.DataGrid1.DataSource = dv;&lt;br /&gt;this.DataBind();&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;Why do I get the error message &quot;ExecuteReader requires an open and available Connection. The connection&#39;s current state is Closed&quot;?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This error is caused if you have not opened the connection. Before you read the data using DataReader open the Connection&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;I get the error message &quot;Keyword not supported: &#39;provider&#39;&quot;, when using Sql Server why?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you are using SqlConnection then the connection string should be as follows:&lt;br /&gt;server=localhost;uid=sa;password=;database=northwind&lt;br /&gt;i.e&lt;br /&gt;server=&lt;yourservername&gt;;uid=&lt;youruid&gt;;password=&lt;yourpassword&gt;;database=&lt;yourdbname&gt;&quot;&lt;br /&gt;&lt;br /&gt;For SqlConnection we do not provide a Provider . Provider is used in cases where OleDbConnection is used.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;I get the error message &quot;Cast from type DBNull to type String is not valid.&quot; when I try to display DataReader values on form?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;If dbReader(&quot;fieldname&quot;).ToString= DBnull.Value.ToString()&lt;br /&gt;  &#39;Empty field value&lt;br /&gt;Else&lt;br /&gt;  &#39;Display value&lt;br /&gt;End if&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;if (dbReader[&quot;fieldname&quot;).ToString() == DBNull.Value.ToString() )&lt;br /&gt;{&lt;br /&gt;  //Empty field value&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;  //display Value&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What is the significance of CommandBehavior.CloseConnection?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To avoid having to explicitly close the connection associated with the command used to create either a SqlDataReader or and OleDbDataReader, pass the CommandBehavior.CloseConnection argument to the ExecuteReader method of the Connection. i.e&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;dr= cmd.ExecuteReader(CommandBehavior.CloseConnection)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;dr= cmd.ExecuteReader(CommandBehavior.CloseConnection);&lt;br /&gt;&lt;br /&gt;The associated connection will be closed automatically when the Close method of the Datareader is called. This makes it all the more important to always remember to call Close on your datareaders.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How to loop through a Dataset to display all records?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;VB.NET&lt;/span&gt;&lt;br /&gt;&#39;Fill Dataset&lt;br /&gt;Dim dc As DataColumn&lt;br /&gt;Dim dr As DataRow&lt;br /&gt;For Each dr In ds.Tables(0).Rows&lt;br /&gt;  For Each dc In ds.Tables(0).Columns&lt;br /&gt;       Response.Write(dr(dc.ColumnName).ToString())&lt;br /&gt;  Next&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 0, 0);&quot;&gt;C#&lt;/span&gt;&lt;br /&gt;//Fill the DataSet&lt;br /&gt;foreach (DataRow dr in ds.Tables[0].Rows)&lt;br /&gt;{&lt;br /&gt;  foreach( DataColumn dc in ds.Tables[0].Columns)&lt;br /&gt;  {&lt;br /&gt;       Response.Write(dr[dc.ColumnName].ToString());&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What is connection pooling?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Connection pooling enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a pool, an application can reuse that connection without performing the complete connection creation process.&lt;br /&gt;&lt;br /&gt;When a user request a connection, it is returned from the pool rather than establishing new connection and, when a user releases a connection, it is returned to the pool rather than being released.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;When is the connection pool created ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When a connection is opened for the first time a connection pool is created and the pool is    determined by the exact match of the connection string in the connection. Each connection pool is associated with a distinct connection string. When a new connection is requested, if the   connection string is not an exact match to an existing pool, a new pool is created.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;When is the connection pool destroyed ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When last connection in the pool is closed the pool is destroyed.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What happens when all the connections in the connection pool are consumed and a new connection request comes?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If the maximum pool size has been reached and no usable connection is available, the request is queued. The connection pooler satisfies these requests by reallocating connections as they are released back into the pool. Connections are released back into the pool when you call Close or  Dispose on the Connection.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How can I enable connection pooling ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For .Net applications it is enabled by default. Well, to make sure the same we can use the    Pooling=true; in the connection string for the SQLConnection Object.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;How can I disable connection pooling?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ADO.NET Data Providers automatically use connection pooling turned on. If you want to turn this functionality off:&lt;br /&gt;&lt;br /&gt; In an SQLConnection object, Add this to the connection string:&lt;br /&gt;&lt;br /&gt; Pooling=False;&lt;br /&gt;&lt;br /&gt; In An OLEDBConnection object, add this:&lt;br /&gt;&lt;br /&gt; OLE DB Services=-4;&lt;br /&gt;&lt;br /&gt;This way, the OLE DB data provider will mark your connection so that it does not participate in  connection pooling.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(0, 0, 102);&quot;&gt;What is a stored procedure?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A stored procedure is a precompiled executable object that contains one or more SQL statements. A stored procedure may be written to accept inputs and return output.&lt;br /&gt;&lt;br /&gt;&lt;/yourdbname&gt;&lt;/yourpassword&gt;&lt;/youruid&gt;&lt;/yourservername&gt;&lt;/product&gt;&lt;/product&gt;&lt;/product&gt;&lt;/product&gt;&lt;/product&gt;&lt;/product&gt;&lt;/products&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/10/adonet-faq.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116124274880101413</guid><pubDate>Thu, 19 Oct 2006 07:04:00 +0000</pubDate><atom:updated>2006-10-19T00:47:28.876-07:00</atom:updated><title>Generate Data Access Layer Classes In Seconds</title><description>While working with the 3-tier applications, we have to write the code for the Data Access Layer (DAL) for most of the database related transactions.&lt;br /&gt;&lt;br /&gt;Assume that we have 25 tables, for each table if we want to write DML operations (like Insert, Select, Delete) then we have to spend most of time to write the same codes on 25 tables.&lt;br /&gt;&lt;br /&gt;i have come across the tool called &quot;MyGeneration 1.1.5.1&quot;, developed by the &lt;strong&gt;MyGeneration Software &lt;/strong&gt;. Check it out.&lt;br /&gt;&lt;br /&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/headline_publisher.2.gif&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;strong&gt;MyGeneration Software&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;a href=&quot;http://photos1.blogger.com/blogger/6079/3972/1600/MyGeneration.jpg&quot;&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/MyGeneration.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;MyGeneration is a development tool written in Microsoft .NET. MyGeneration generates code from templates that can be written in C#, VB.NET, JScript, and VBScript. MyGeneration is for generating ORM architectures or O/R Mapping files for architectures such as Gentle.NET, and NHibernate. The meta-data from your database is made available to your templates through the MyMeta API. MyGeneration supports Microsoft SQL, Oracle, IBM DB2, MySQL, PostgreSQL, Microsoft Access, FireBird, Interbase, SQLite, VistaDB and Advantage. MyGeneration can generate code for non-Microsoft operating systems. MyGeneration installs with many sample templates that generate C# and VB.NET code, Stored Procedures, PHP, HTML. Adapt our templates or write your own to generate your particular architecture. MyGeneration also offers its own .NET architecture known as dOOdads, it&#39;s available in C# and VB.NET.&lt;br /&gt;&lt;br /&gt;Version 1.1.5.1 features: GuiLabel has new Bold, Italic, and Strikethrough properties.&lt;br /&gt;&lt;br /&gt;Download at : &lt;a href=&quot;http://www.download.com/3000-20-10343918.html?part=undefined&amp;subj=dl&amp;amp;tag=button&quot;&gt;&lt;img alt=&quot;Get it from CNET Download.com!&quot; src=&quot;http://i.i.com.com/cnwk.1d/i/dl/dl-bta.gif&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/10/generate-data-access-layer-classes-in.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116124106616343941</guid><pubDate>Thu, 19 Oct 2006 06:39:00 +0000</pubDate><atom:updated>2006-10-18T23:59:29.690-07:00</atom:updated><title>Advanced JavaScript Editor</title><description>As a web developer, we know the importance of javascript for client side validations, working with images and forms. Except visul studio, not any other editors support javascipt debugging. But using visual studio also, it&#39;s not that easy to debug the javascript functions.&lt;br /&gt;&lt;br /&gt;i have come across the &quot;JavaScript Editor&quot; developed by the &lt;strong&gt;Yaldex Software&lt;/strong&gt;, which provides the javascript function debugging a lot easier.&lt;br /&gt;&lt;br /&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/headline_publisher.1.gif&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;strong&gt;Yaldex Software&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href=&quot;http://photos1.blogger.com/blogger/6079/3972/1600/javascript-1.jpg&quot;&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/javascript-1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;1st JavaScript Editor is advanced JavaScript Editor, Validator and Debugger for beginners and professionals. Beside rich possibilities of editing scripts (JavaScript, HTML, CSS and syntax highlighting), program offers an excellent source code formatter / beautifier, which allows you to customize and apply any style you want. Built-in JavaScript Debugger will allow you run and debug the code, one line at a time. JavaScript Editor is used for professionally editing JavaScript code and creating animations and other special effects for Web pages using DHTML, CSS, Ajax, and JavaScript.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://photos1.blogger.com/blogger/6079/3972/1600/javascript-2.jpg&quot;&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/javascript-2.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;First JavaScript Editor can help you navigate through code using built-in &#39;Functions and Variables&#39; navigator. Program uses Intellisense to simplify writing code and can highlight matching curly braces. Context help gives you access to over 2000 methods, properties. Unique library contains 200 controlled and 700 not controlled scripts. AJAX developers can easily use this program as advanced Ajax Editor. Version 3.7 may include unspecified updates, enhancements, or bug fixes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Download at: &lt;a href=&quot;http://www.download.com/3000-20-10458409.html?part=undefined&amp;subj=dl&amp;tag=button&quot;&gt;&lt;img src=&quot;http://i.i.com.com/cnwk.1d/i/dl/dl-bta.gif&quot; alt=&quot;Get it from CNET Download.com!&quot; border=&quot;0&quot;&gt;&lt;/a&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/10/advanced-javascript-editor.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116123956272149370</guid><pubDate>Thu, 19 Oct 2006 05:57:00 +0000</pubDate><atom:updated>2006-10-18T23:37:42.396-07:00</atom:updated><title>Graphical Tool for SQL Server administration</title><description>Microsoft SQL Server 2005 Express Edition doesn&#39;t provide you the Management tool. So if you want to use the management tool, you have to download the &lt;a href=&quot;http://msdn.microsoft.com/vstudio/express/sql/&quot;&gt;Management tool&lt;/a&gt; in order to use that, but it supports only for SQL Server 2005.&lt;br /&gt;&lt;br /&gt;I found out the new tool &#39;SQL Manager 2005&#39;, which is provided by the &lt;strong&gt;EMS Database Management Solutions&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://photos1.blogger.com/blogger/6079/3972/1600/headline_publisher.0.gif&quot;&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/headline_publisher.0.gif&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;EMS Database Management Solutions&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;a href=&quot;http://photos1.blogger.com/blogger/6079/3972/1600/SQLServer2005-1.jpg&quot;&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/SQLServer2005-1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;EMS SQL Manager for SQL Server is a powerful graphical tool for SQL Server administration and development. SQL Manager 2005 works with any SQL Server versions from 7 to 2005 and supports all of the latest SQL Server features including new SQL Server 2005 permission system, assemblies, DDL triggers, XML columns.&lt;br /&gt;It offers plenty of powerful tools for experienced users such as Visual Database Designer and Visual Query Builder to satisfy all their needs. Version 2.5.0.1 may include unspecified updates, enhancements, or bug fixes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Download at : &lt;a href=&quot;http://www.download.com/3000-20-10406588.html?part=undefined&amp;subj=dl&amp;tag=button&quot;&gt;&lt;img src=&quot;http://i.i.com.com/cnwk.1d/i/dl/dl-bta.gif&quot; alt=&quot;Get it from CNET Download.com!&quot; border=&quot;0&quot;&gt;&lt;/a&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/10/graphical-tool-for-sql-server.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116123694327805041</guid><pubDate>Thu, 19 Oct 2006 05:34:00 +0000</pubDate><atom:updated>2006-10-18T23:39:19.423-07:00</atom:updated><title>Develop ASP.NET Menu using UltimateMenu tool</title><description>Generally for displaying menu on web pages, we can use javascript or DHTML, but it doesn&#39;t provide you the server side functionality. In order to get the server side functionality for the menu, we can use tool like UltimateMenu. For example, if we want to display the data in menu which comes from database, hope that this one would be useful.&lt;br /&gt;&lt;br /&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px;&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/headline_publisher.gif&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;strong&gt;Karamasoft&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/6079/3972/320/UltimateMenu.0.jpg&quot; border=&quot;0&quot; /&gt;UltimateMenu is an ASP.NET menu control to build advanced DHTML menus. Visual Designer--fully integrated into VS.NET, also available as a stand-alone ASP.NET application. Frame support--full frame support without a single line of coding. User rights--display different parts of the menu based on user credentials. Data Binding--load menu from a data source as easy as setting a connection string. Professional style--pop-up, drop-down, vertical, horizontal, scrolling, filter, transition.&lt;br /&gt;&lt;br /&gt;Show path--display both the menu traversal path, and the actual navigation path with different style. Client &amp; server events--raise client-side and server-side events when user clicks on menu items. XML &amp;amp; CSS--menu structure and style based on XML and CSS industry standards. XHTML Support--fully compliant with XHTML. Cross-Browser support--IE5+, NS6+, Firefox 1.0+, Mozilla 1.0+, Opera 7.5+ for the best outcome, all down-level browsers with limited functionality.&lt;br /&gt;&lt;br /&gt;Download at &lt;a href=&quot;http://www.download.com/3000-20-10131627.html?part=undefined&amp;subj=dl&amp;amp;tag=button&quot;&gt;&lt;img alt=&quot;Get it from CNET Download.com!&quot; src=&quot;http://i.i.com.com/cnwk.1d/i/dl/dl-bta.gif&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/10/develop-aspnet-menu-using-ultimatemenu.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116108400013500496</guid><pubDate>Tue, 17 Oct 2006 11:01:00 +0000</pubDate><atom:updated>2006-10-17T04:20:00.246-07:00</atom:updated><title>Dynamically add controls to the Repeater control</title><description>Some times we have to add dynamic controls to the repeater (or) datagrid columns based on the conditions. For placing the dynamic controls, we need placeholder control in datagrid. You can think of a PlaceHolder control as an empty container to which you can add your controls. ASP.NET will remember the values for your dynamic controls; however, you do have to create the controls both on non-postback and postback calls. Once the controls are created in postback mode, ASP.NET will re-associate the posted data with the dynamic controls and repopulate the data automatically.&lt;br /&gt;&lt;br /&gt;This example has a table called Parameters that has the following fields to help you determine how to build the table:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table cellpadding=&quot;1&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;middle&quot;&gt;&lt;strong&gt;Field&lt;/strong&gt;&lt;/td&gt;&lt;td align=&quot;middle&quot;&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;pkParameterID&lt;/td&gt;&lt;td&gt;Primary key&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Prompt&lt;/td&gt;&lt;td&gt;Text to display next to control&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DataType&lt;/td&gt;&lt;td&gt;Text field with the value &#39;String&#39; or &#39;TF&#39; in it (This will let you determine which control to show.)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;You also could add extra fields indicating whether the field was required, a minimum/maximum length, and so forth, but this example is designed to show just the use of the PlaceHolder control.&lt;/p&gt;&lt;p&gt;You then can create a simple form like this one:&lt;/p&gt;&lt;br /&gt;&lt;font color=&quot;blue&quot;&gt;&lt;br /&gt;&amp;#60;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot;&lt;br /&gt;                       CodeFile=&quot;test.aspx.cs&quot; Inherits=&quot;test&quot; %&amp;#62;&lt;br /&gt;&amp;#60;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;br /&gt;               &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-&lt;br /&gt;                transitional.dtd&quot;&amp;#62;&lt;br /&gt;&amp;#60;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &amp;#62;&lt;br /&gt;&amp;#60;head runat=&quot;server&quot;&amp;#62;&lt;br /&gt;   &amp;#60;title&amp;#62;Untitled Page&amp;#60;/title&amp;#62;&lt;br /&gt;&amp;#60;/head&amp;#62;&lt;br /&gt;&amp;#60;body&amp;#62;&lt;br /&gt;   &amp;#60;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;#62;&lt;br /&gt;   &amp;#60;div&amp;#62;&lt;br /&gt;      &amp;#60;asp:Repeater ID=&quot;rptFields&quot; runat=&quot;server&quot;&amp;#62;&lt;br /&gt;         &amp;#60;HeaderTemplate&amp;#62;&lt;br /&gt;         &amp;#60;table&amp;#62;&lt;br /&gt;         &amp;#60;/HeaderTemplate&amp;#62;&lt;br /&gt;         &amp;#60;ItemTemplate&amp;#62;&lt;br /&gt;            &amp;#60;tr&amp;#62;&lt;br /&gt;               &amp;#60;td&amp;#62;&amp;#60;%# Eval(&quot;Prompt&quot;) %&amp;#62;:&amp;#60;/td&amp;#62;&lt;br /&gt;               &amp;#60;td&amp;#62;&amp;#60;asp:PlaceHolder ID=&quot;plControl&quot; runat=&quot;server&quot; /&amp;#62;&lt;br /&gt;               &amp;#60;input type=&quot;hidden&quot; id=&quot;hdnFieldID&quot; runat=&quot;server&quot;&lt;br /&gt;                  value=&#39;&amp;#60;%# Eval(&quot;pkParameterID&quot;) %&amp;#62;&#39; /&amp;#62;&amp;#60;/td&amp;#62;&lt;br /&gt;            &amp;#60;/tr&amp;#62;&lt;br /&gt;         &amp;#60;/ItemTemplate&amp;#62;&lt;br /&gt;         &amp;#60;FooterTemplate&amp;#62;&lt;br /&gt;         &amp;#60;/table&amp;#62;&lt;br /&gt;         &amp;#60;/FooterTemplate&amp;#62;&lt;br /&gt;      &amp;#60;/asp:Repeater&amp;#62;&lt;br /&gt;      &amp;#60;p align=&quot;center&quot;&amp;#62;&amp;#60;asp:LinkButton ID=&quot;btnSubmit&quot;&lt;br /&gt;         runat=&quot;server&quot;&amp;#62;Submit Data&amp;#60;/asp:LinkButton&amp;#62;&amp;#60;/p&amp;#62;&lt;br /&gt;   &amp;#60;/div&amp;#62;&lt;br /&gt;   &amp;#60;/form&amp;#62;&lt;br /&gt;&amp;#60;/body&amp;#62;&lt;br /&gt;&amp;#60;/html&amp;#62;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;The code behind for this page looks like this:&lt;br /&gt;&lt;font color=&quot;blue&quot;&gt;&lt;br /&gt;public partial class test : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;   protected override void OnInit(EventArgs e)&lt;br /&gt;   {&lt;br /&gt;      base.OnInit(e);&lt;br /&gt;      rptFields.ItemDataBound +=&lt;br /&gt;         new RepeaterItemEventHandler(rptFields_ItemDataBound);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;   {&lt;br /&gt;      Database db = new Database(&quot;(local)&quot;, &quot;test&quot;, &quot;sa&quot;, &quot;dev1227&quot;);&lt;br /&gt;      AddControls(db);&lt;br /&gt;      db.Close();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   private void AddControls(Database db)&lt;br /&gt;   {&lt;br /&gt;      DataTable dt = db.GetDataTableAdhoc(&quot;SELECT * FROM Parameters&lt;br /&gt;                                           ORDER BY pkParameterID&quot;);&lt;br /&gt;      rptFields.DataSource = dt;&lt;br /&gt;      rptFields.DataBind();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   void rptFields_ItemDataBound(object sender, RepeaterItemEventArgs e)&lt;br /&gt;   {&lt;br /&gt;      if (e.Item.ItemType != ListItemType.Item &amp;&amp; e.Item.ItemType&lt;br /&gt;          != ListItemType.AlternatingItem)&lt;br /&gt;         return;&lt;br /&gt;&lt;br /&gt;      DataRow dr = ((DataRowView)e.Item.DataItem).Row;&lt;br /&gt;      PlaceHolder pl = (PlaceHolder)e.Item.FindControl(&quot;plControl&quot;);&lt;br /&gt;      switch (dr[&quot;DataType&quot;].ToString().ToLower())&lt;br /&gt;      {&lt;br /&gt;         case &quot;string&quot;:&lt;br /&gt;            TextBox txt = new TextBox();&lt;br /&gt;            txt.ID = &quot;txtField&quot; + dr[&quot;pkParameterID&quot;].ToString();&lt;br /&gt;            pl.Controls.Add(txt);&lt;br /&gt;            break;&lt;br /&gt;&lt;br /&gt;         case &quot;tf&quot;:&lt;br /&gt;            CheckBox chk = new CheckBox();&lt;br /&gt;            chk.ID = &quot;chkField&quot; + dr[&quot;pkParameterID&quot;].ToString();&lt;br /&gt;            pl.Controls.Add(chk);&lt;br /&gt;            break;&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;As you see in the Page_Load routine, you need to load the dynamic controls every time—not just on the initial load of the page. I create an instance of my Database class, which encapsulates all my database code. Replace this with your favorite data access routine, but the sample uses a DataTable holding the contents of the Parameters table, which is bound against the Repeater control.&lt;br /&gt;&lt;br /&gt;The ItemDataBound event does the bulk of the work here. It first determines that you are looking at an ItemTemplate (or AlternatingItemTemplate), and then it grabs the DataRow from the event arguments. This row holds the data type for the parameter, and a switch statement lets you get to the right area to add the right control. In each case, you instantiate a control of the appropriate type (TextBox vs. CheckBox) and then add it to the placeholder control (held in the pl variable). This causes the control to be displayed to the user.&lt;br /&gt;&lt;br /&gt;If you wanted to give the control a default value, you&#39;d need to check whether you were in postback mode prior to putting the value into the control or checking the box by default. If you didn&#39;t do this check, you&#39;d essentially erase the user&#39;s input each time.&lt;br /&gt;&lt;br /&gt;In the test page, you can type your data in and then press the Submit button. The Submit button will reload the page, which will show you that the values you typed in are repopulated automatically via the page&#39;s view state. This is a handy technique for building dynamic forms, especially those driven from user-configurable data.</description><link>http://dotnetlibrary.blogspot.com/2006/10/dynamically-add-controls-to-repeater.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>52</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116107530037574076</guid><pubDate>Tue, 17 Oct 2006 07:40:00 +0000</pubDate><atom:updated>2006-10-17T02:52:32.020-07:00</atom:updated><title>Adding Multiple Checkbox Items to Datagrid for Selecting, Confirming and Deleting the Selected Data</title><description>As a .Net developer, we know the importance of the datagrid in web applications. In ASP days, we used to write the code to generate the data in table format and add bit of complex code for paging and sorting of the data.&lt;br /&gt;&lt;br /&gt;To avoid this much code and to make developer HAPPY, Microsoft came up with nice and cool control called &lt;strong&gt;Datagrid&lt;/strong&gt; with minmum code and have the features like paging and sorting.&lt;br /&gt;&lt;br /&gt;But some times we have to select the data from the datagrid then we process the data for modifying or deleting the data. So for that generally we add checkbox control to the for each row of the datagrid, so based on that we will select the checkbox for further processing of the data.&lt;br /&gt;&lt;br /&gt;Here i am explaining the steps to add the checkbox to the datagrid and little of coding to select data for further processing.&lt;br /&gt;&lt;br /&gt;In this article, we will examine how to create a fully functional DataGrid with all the features like seelctign the data for further processing. As an added bonus we&#39;ll be performing all of our data tasks strictly utilizing Microsoft&#39;s new &lt;a href=&quot;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp&quot; target=&quot;_blank&quot;&gt;Data Access Application Block or DAAB v2&lt;/a&gt;. To any who may feel a little behind with DAAB, have no fear, everything here can still be accomplished with pre-DAAB data objects as the only difference here is the data access part of it. Trust me there is a huge difference between the two, for one DAAB enable you to write about 75% less code that you would normally need when compared with regular ADO.NET!&lt;br /&gt;&lt;br /&gt;So, before we begin, download the DAAB dll from the above link, install it, and copy it into you application&#39;s bin folder and you&#39;re ready to go. Also, be sure and take a peek at the DAAB documentation that came with your installation for an overview and any questions you may have.&lt;br /&gt;&lt;br /&gt;Ok, let&#39;s get to it then.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Our fully-featured DataGrid&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Selecting &amp; deleting multiple items will definitely be set up quite differently than any other type of .NET DataGrid deleting you probably have seen. However, we&#39;ll still follow the same logical flow of deletion, and we&#39;ll still confirm any delete actions about to take place after we have selected all our items. Much of the magic in making this work is really going to come from client-side JavaScript, that is ultimately responsible for wiring up our main &quot;select all&quot; checkbox to handle the selecting and deselecting of our checkboxes. Also, included is our server-side delete method that erases our data, and a DataGrid refresher method to rebind our DataGrid after we have completed our data deletion.&lt;br /&gt;&lt;br /&gt;Have a look at Figure 1 to get an idea of what your DataGrid will look like:&lt;br /&gt;&lt;br /&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://www.developerfusion.co.uk/res/content/4632/Image1/&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Figure 1 &lt;br /&gt;&lt;br /&gt;Here is the code to set up our DataGrid: &lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;&amp;#60;form runat=&quot;server&quot; ID=&quot;Form1&quot;&amp;#62;&lt;br /&gt;    &amp;#60;h3&amp;#62;Selecting, Confirming &amp;amp; Deleting Multiple Checkbox Items In A DataGrid &amp;#60;/h3&amp;#62;&lt;br /&gt;     &amp;#60;br&amp;#62;&lt;br /&gt;     &amp;#60;ASP:DataGrid id=&quot;MyDataGrid&quot; runat=&quot;server&quot; Width=&quot;700&quot; BackColor=&quot;white&quot; BorderColor=&quot;black&quot; CellPadding=&quot;3&quot; CellSpacing=&quot;0&quot; Font-Size=&quot;9pt&quot; AutoGenerateColumns=&quot;False&quot; HeaderStyle-BackColor=&quot;darkred&quot; HeaderStyle-ForeColor=&quot;white&quot;&amp;#62;&lt;br /&gt;         &amp;#60;Columns&amp;#62;&lt;br /&gt;&amp;#60;asp:TemplateColumn&amp;#62;&lt;br /&gt;                &amp;#60;HeaderTemplate&amp;#62;&lt;br /&gt;                    &amp;#60;asp:CheckBox ID=&quot;CheckAll&quot; OnClick=&quot;javascript: return select_deselectAll (this.checked, this.id);&quot;&lt;br /&gt;                        runat=&quot;server&quot; /&amp;#62;&lt;br /&gt;                    &amp;#60;font face=&quot;Webdings&quot; color=&quot;white&quot; size=&quot;4&quot;&amp;#62;a&amp;#60;/font&amp;#62;&lt;br /&gt;                &amp;#60;/HeaderTemplate&amp;#62;&lt;br /&gt;                &amp;#60;ItemTemplate&amp;#62;&lt;br /&gt;                    &amp;#60;asp:CheckBox ID=&quot;DeleteThis&quot; OnClick=&quot;javascript: return select_deselectAll (this.checked, this.id);&quot;&lt;br /&gt;                        runat=&quot;server&quot; /&amp;#62;&lt;br /&gt;                &amp;#60;/ItemTemplate&amp;#62;&lt;br /&gt;            &amp;#60;/asp:TemplateColumn&amp;#62;&lt;br /&gt;// ... Rest of our Custom Template &amp; Bound Columns&lt;br /&gt;&amp;#60;/Columns&amp;#62;&lt;br /&gt;&amp;#60;/form&amp;#62;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;The code listed above is what makes our DataGrid set up behave just like the grids on Hotmail and Yahoo. Our .NET DataGrid will have the same functionality and options available for selecting however many items, or perhaps all, that you&#39;d like to delete, and once you do and submit, kiss them goodbye.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Selecting and De-Selecting our Checkboxes&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Now that both checkboxes are wired to our multi-faceted JavaScript method, how is that one function going to determine the checkbox its dealing with, and the action it needs to carry out? Ah, here&#39;s how :-) &lt;br /&gt;&lt;br /&gt;Our function &lt;font color=&quot;#8E2323&quot;&gt;select_deselectAll&lt;/font&gt;, listed below, accepts two arguments: the Checkbox&#39;s checked value, and its ID. Once this function is called, and its two arguments have been passed in, it&#39;ll begin looping through our form. Next, it begins performing some conditional checking utilizing JavaScript&#39;s &lt;font color=&quot;#8E2323&quot;&gt;indexOf&lt;/font&gt; method to locate the appropriate checkbox, and is based on both the values passed in, which it turn ultimately will give us one of several causes and effects: &lt;br /&gt;&lt;br /&gt;If the main &quot;select all&quot; checkbox is checked, it will select all of the DataGrid checkboxes &lt;br /&gt;If the main &quot;select all&quot; checkbox is unchecked, then all of the DataGrid checkboxes get unselected &lt;br /&gt;Finally, if after the main &quot;select all&quot; checkbox is selected and all of the DataGrid&#39;s checkboxes are all checked, any one of those checkboxes gets unchecked, then the main checkbox is also unchecked. This way we don&#39;t end up having our checkbox&#39;s logic behaving inconsistently or erratically. &lt;br /&gt;&lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;function select_deselectAll (chkVal, idVal) &lt;br /&gt;{ &lt;br /&gt;    var frm = document.forms[0];&lt;br /&gt;    // Loop through all elements&lt;br /&gt;    for (i=0; i&amp;#60;frm.length; i++) &lt;br /&gt;    {&lt;br /&gt;        // Look for our Header Template&#39;s Checkbox&lt;br /&gt;        if (idVal.indexOf (&#39;CheckAll&#39;) != -1) &lt;br /&gt;        {&lt;br /&gt;            // Check if main checkbox is checked, then select or deselect datagrid checkboxes &lt;br /&gt;            if(chkVal == true) &lt;br /&gt;            {&lt;br /&gt;                frm.elements[i].checked = true;&lt;br /&gt;            } &lt;br /&gt;            else &lt;br /&gt;            {&lt;br /&gt;                frm.elements[i].checked = false;&lt;br /&gt;            }&lt;br /&gt;            // Work here with the Item Template&#39;s multiple checkboxes&lt;br /&gt;        } &lt;br /&gt;        else if (idVal.indexOf (&#39;DeleteThis&#39;) != -1) &lt;br /&gt;        {&lt;br /&gt;            // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox&lt;br /&gt;            if(frm.elements[i].checked == false) &lt;br /&gt;            {&lt;br /&gt;                frm.elements[1].checked = false; //Uncheck main select all checkbox&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;Figure 2 shows you the effect of the JavaScript above interacting with the DataGrid when selecting the top main &quot;select all&quot; checkbox. &lt;br /&gt;&lt;br /&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://www.developerfusion.co.uk/res/content/4632/Image2/&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Figure 2 &lt;br /&gt;&lt;br /&gt;Now, aside from this function allowing a quick full selection, you also have the option of manually selecting as many checkbox items as you wish. Next comes the tricky part in how to determine which ones were selected, and how to confirm this the instant you submit the form, and prior to actual deletion. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Confirming Multiple Deletes&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In this section, we&#39;ll examine how to confirm multiple deletes when we submit our form. Below in Figure 3 you can now see the alert confirmation after selecting a couple of items, and then submitting the form by press the &quot;Delete Items&quot; button. The alert takes place at any time you submit the form (as long as you have more than one checkbox selected). &lt;br /&gt;&lt;br /&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://www.developerfusion.co.uk/res/content/4632/Image3/&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Figure 3&lt;br /&gt;&lt;br /&gt;Note that this confirmation will alert with all checkboxes selected or a just a few as shown. Pressing the Delete Items button with none selected will not prompt any alert. Here now is how we determine what checkboxes are actually checked. &lt;br /&gt;&lt;br /&gt;The first thing we did was set up our Delete Button at the end of our DataGrid; just a regular asp server button. We also wired a server-side event to it &lt;font color=&quot;#8E2323&quot;&gt;- DeleteStore - &lt;/font&gt;that, when confirmed, will delete the records: &lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;&amp;#60;asp:Button Text=&quot;Delete Items&quot; OnClick=&quot;DeleteStore&quot; ID=&quot;Confirm&quot; runat=&quot;server&quot; /&amp;#62;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;But how does that pop-up alert confirmation appear? Well, that&#39;s the cool thing. We get this by adding the code listed below to our Button server control as soon as the page loads, in our &lt;font color=&quot;#8E2323&quot;&gt;Page_Load&lt;/font&gt; method, by locating it using the &lt;font color=&quot;#8E2323&quot;&gt;FindControl&lt;/font&gt; method and then adding to the button attributes, like so: &lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;WebControl button = (WebControl) Page.FindControl(&quot;Confirm&quot;); &lt;br /&gt;button.Attributes.Add (&quot;onclick&quot;, &quot;return confirmDelete (this.form);&quot;); &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;So, the second the page loads, it attached the Javascript handler to this button, and if you examine the HTML source code, the button afterwords, actually looks like this:&lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;&amp;#60;input type=&quot;submit&quot; name=&quot;Confirm&quot; value=&quot;Delete Items&quot; id=&quot;Confirm&quot; onclick=&quot;return confirmDelete (this.form);&quot; /&amp;#62;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Cool huh? Now, the second this button is pressed, is when it can now trigger the client side JavaScript function below: &lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;function confirmDelete (frm) &lt;br /&gt;{ &lt;br /&gt;    // loop through all elements&lt;br /&gt;    for (i=0; i&amp;#60;frm.length; i++) &lt;br /&gt;    {&lt;br /&gt;        // Look for our checkboxes only&lt;br /&gt;        if (frm.elements[i].name.indexOf(&quot;DeleteThis&quot;) !=-1) &lt;br /&gt;        {&lt;br /&gt;            // If any are checked then confirm alert, otherwise nothing happens&lt;br /&gt;            if(frm.elements[i].checked) &lt;br /&gt;            {&lt;br /&gt;                return confirm (&#39;Are you sure you want to delete your selection(s)?&#39;)&lt;br /&gt;                }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;Ok, what happening here? Well, the JS function above is, for all intents and purposes, not that different from the previous JavaScript function - &lt;font color=&quot;#8E2323&quot;&gt;select_deselectAll&lt;/font&gt;. Except, instead of determining if the main &quot;select all&quot; checkbox is checked, it actually checks to see whether if any of the DataGrid row checkboxes are checked. If so, it&#39;ll then, and only then, alert you with a confirmation to proceed onto either to delete or cancel. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Deleting Data  &lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;Now recall our &lt;font color=&quot;#8E2323&quot;&gt;asp:button&lt;/font&gt; above, and its default JavaScript onclick event handler attached on &lt;font color=&quot;#8E2323&quot;&gt;Page_Load&lt;/font&gt;. Aside from this we also notice it has another &lt;font color=&quot;#8E2323&quot;&gt;OnClick&lt;/font&gt; event (this one being server based) that gets raised when the button is clicked, rather pressed, that&#39;ll allow it to fire the server-side &lt;font color=&quot;#8E2323&quot;&gt;DeleteStore&lt;/font&gt; method to delete our data: &lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;public void DeleteStore (Object sender, EventArgs e) &lt;br /&gt;{&lt;br /&gt;    string dgIDs = &quot;&quot;;&lt;br /&gt;    bool BxsChkd = false; &lt;br /&gt;    foreach (DataGridItem i in MyDataGrid.Items) &lt;br /&gt;    {&lt;br /&gt;        CheckBox deleteChkBxItem = (CheckBox) i.FindControl (&quot;DeleteThis&quot;);&lt;br /&gt;        if (deleteChkBxItem.Checked) &lt;br /&gt;        {&lt;br /&gt;            BxsChkd = true;&lt;br /&gt;            // Concatenate DataGrid item with comma for SQL Delete&lt;br /&gt;            dgIDs += ((Label) i.FindControl (&quot;StoreID&quot;)).Text.ToString() + &quot;,&quot;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    // Set up SQL Delete statement, using LastIndexOf to remove tail comma from string.&lt;br /&gt;    string deleteSQL = &quot;DELETE from Stores WHERE stor_id IN (&quot; + dgIDs.Substring (0, dgIDs.LastIndexOf (&quot;,&quot;)) + &quot;)&quot;;&lt;br /&gt;&lt;br /&gt;    if (BxsChkd == true) &lt;br /&gt;    { // Execute SQL Query only if checkboxes are checked, otherwise error occurs with initial null string&lt;br /&gt;        try &lt;br /&gt;        {&lt;br /&gt;            SqlHelper.ExecuteNonQuery (objConnect, CommandType.Text, deleteSQL);&lt;br /&gt;            OutputMsg.InnerHtml += &quot;&amp;#60;font size=4&amp;#62;&amp;#60;b&amp;#62;Store information has been deleted.&amp;#60;/b&amp;#62;&amp;#60;/font&amp;#62;&quot;;&lt;br /&gt;            OutputMsg.Style[&quot;color&quot;] = &quot;green&quot;;&lt;br /&gt;        } &lt;br /&gt;        catch (SqlException err) &lt;br /&gt;        { &lt;br /&gt;            OutputMsg.InnerHtml += err.Message.ToString(); //&quot;&amp;#60;font size=4&amp;#62;&amp;#60;b&amp;#62;An error occurred and the record could not be deleted&amp;#60;/b&amp;#62;&amp;#60;/font&amp;#62;&quot;;&lt;br /&gt;            OutputMsg.Style[&quot;color&quot;] = &quot;red&quot;;&lt;br /&gt;        }&lt;br /&gt;        //Refresh data&lt;br /&gt;        BindData();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;Since having wired the two client/server methods together, it&#39;s our JavaScript code that actually intercepts this button&#39;s call and goes first. If you confirm OK, then will the deleting server-side method execute, otherwise it&#39;ll cancel all events after that point and prevent anything from posting back. &lt;br /&gt;&lt;br /&gt;Looking at the &lt;font color=&quot;#8E2323&quot;&gt;DeleteStore()&lt;/font&gt; method, you&#39;ll notice that it is actually does a few things. First, it set&#39;s up the string variable &lt;font color=&quot;#8E2323&quot;&gt;dgIDs&lt;/font&gt; that will hold all of our selected DataGrid IDs. Next, it loops through the DataGrid, and gathers all of the selected item ids that are based on the row&#39;s TemplateColumn ID, which is why I kept the ID control as a TemplateColumn and the rest BoundColumns as these types of controls do not support the ID property we need for referencing our data. After this, it will, upon verifying checked items, gather all the ids and assign them to our &lt;font color=&quot;#8E2323&quot;&gt;dgIDs&lt;/font&gt; variable, that&#39;ll be used with our SQL &lt;font color=&quot;#8E2323&quot;&gt;deleteSQL&lt;/font&gt; delete statement. &lt;br /&gt;&lt;br /&gt;The &lt;font color=&quot;#8E2323&quot;&gt;deleteSQL&lt;/font&gt; delete statement uses the &quot;&lt;font color=&quot;#8E2323&quot;&gt;WHERE IN&lt;/font&gt;&quot; argument to perform the multiple deletes in one shot. Since we need to separate each id with a comma, you&#39;ll notice that in the loop I attach a comma after each collected item. This way we&#39;ll have all of our items clearly defined in our SQL. One problem however is that since we add on a comma after each collected item, the last one as well will include a tail-end comma and SQL won&#39;t like this. For example, once we loop through the DataGrid, gather up all of the selected items, and assign it to our delete string we could end up with something like this: &lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;DELETE from Stores WHERE stor_id IN (2,4,6,7,) &lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Notice the last comma; that&#39;s a no-no. To quickly and easily remedy this, we must remove the last comma, and we do this by pulling the substring we need from the &quot;&lt;font color=&quot;#8E2323&quot;&gt;dgIDs&lt;/font&gt;&quot; string using &lt;font color=&quot;#8E2323&quot;&gt;LastIndexOf (&quot;,&quot;)&lt;/font&gt; effectively removing the last comma, and properly formatting the delete statement for SQL, like so: &lt;br /&gt;&lt;font color=blue&gt;&lt;br /&gt;DELETE from Stores WHERE stor_id IN (2,4,6,7) &lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Finally, &lt;font color=&quot;#8E2323&quot;&gt;DeleteStore&lt;/font&gt; proceeds to execute the query against the database. Incidentally, for those wondering why I have a conditional with &lt;font color=&quot;#8E2323&quot;&gt;BxsChkd&lt;/font&gt;? Well it&#39;s because if I don&#39;t initially select any items, I&#39;m returned an error on &lt;font color=&quot;#8E2323&quot;&gt;Page_Load&lt;/font&gt; due to our &lt;font color=&quot;#8E2323&quot;&gt;SqlHelper&lt;/font&gt; having nothing initialized. Therefore, by do so, our &lt;font color=&quot;#8E2323&quot;&gt;DeleteStore&lt;/font&gt; method will remain silent, and happily waiting in the wings until it does get the actual go ahead. &lt;br /&gt;&lt;br /&gt;So that&#39;s the crux of our DataGrid application, and technology behind doing multiple checkbox deletes.</description><link>http://dotnetlibrary.blogspot.com/2006/10/adding-multiple-checkbox-items-to.html</link><author>noreply@blogger.com (Vijay Kumar)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116097511080626738</guid><pubDate>Mon, 16 Oct 2006 04:38:00 +0000</pubDate><atom:updated>2006-10-15T22:10:32.166-07:00</atom:updated><title>How to debug T-SQL stored procedures</title><description>&lt;p&gt;I will execute -- or step into -- a sample T-SQL stored procedure and assign values to input parameters, inspect variable contents, follow the logical flow of the procedure during runtime, evaluate T-SQL expressions, view the procedure&#39;s output, set breakpoints and generally examine the state of the environment. (Future tips will continue along this same theme.) We will debug our procedure, not from Management Studio but from the Visual Studio 2005 development environment. I mention this because under SQL Server 2000 we are able to debug stored procedures using Query Analyzer. Perhaps debugging capabilities will be added to Management Studio in the future. &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Sample stored procedure&lt;/li&gt;&lt;li&gt;Where to start debugging the stored procedure&lt;/li&gt;&lt;li&gt;How to step into or run the stored procedure&lt;/li&gt;&lt;li&gt;Visual Studio debug windows&lt;/li&gt;&lt;li&gt;Conclusions &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Sample T-SQL stored procedure: P_DisplayProductDetails&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Our sample stored procedure displays product details from the AdventureWorks database using a function to rank the unit price for each product subcategory. The procedure accepts the category name as an optional input parameter. Several output parameters feed useful information back to the calling batch.&lt;/p&gt;&lt;p align=&quot;left&quot;&gt;&lt;br /&gt;Use AdventureWorks&lt;br /&gt;GO&lt;br /&gt;IF EXISTS (SELECT * FROM sysobjects WHERE type = &#39;P&#39; AND name = &#39;P_DisplayProductDetails&#39;)&lt;br /&gt;DROP Procedure P_DisplayProductDetails&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE Procedure P_DisplayProductDetails&lt;br /&gt;(@Categoryname varchar(50) = NULL,&lt;br /&gt;@MatchingRows int = NULL OUTPUT,&lt;br /&gt;@ErrorString varchar(128) = NULL OUTPUT,&lt;br /&gt;@ErrorNumber int = NULL OUTPUT)&lt;br /&gt;&lt;br /&gt;as&lt;br /&gt;&lt;br /&gt;BEGIN TRY&lt;br /&gt;-- Append a % so our callers don&#39;t have to know exact subcategory names&lt;br /&gt;if @CategoryName is null&lt;br /&gt;select @CategoryName = &#39;%&#39;&lt;br /&gt;else&lt;br /&gt;select @CategoryName = @CategoryName + &#39;%&#39;&lt;br /&gt;&lt;br /&gt;-- Use a rank function to rank data by List Price over subcategory name&lt;br /&gt;-- The DENSE_RANK assigns consecutive rank values&lt;br /&gt;&lt;br /&gt;SELECT Production.Product.ProductID,&lt;br /&gt;Production.Product.Name AS ProductName,&lt;br /&gt;Production.ProductCategory.Name AS CategoryName,&lt;br /&gt;Production.ProductSubcategory.Name AS SubcategoryName, Production.Product.ListPrice,DENSE_RANK() over (Partition by Production.ProductSubcategory.Name ORDER BY Production.Product.ListPrice DESC) as PriceRank&lt;br /&gt;FROM Production.Product&lt;br /&gt;INNER JOIN&lt;br /&gt;Production.ProductSubcategory ON Production.Product.ProductSubcategoryID =&lt;br /&gt;Production.ProductSubcategory.ProductSubcategoryID&lt;br /&gt;INNER JOIN Production.ProductCategory ON Production.ProductSubcategory.ProductCategoryID = Production.ProductCategory.ProductCategoryID&lt;br /&gt;WHERE Production.ProductCategory.Name like @CategoryName ORDER BY Production.ProductCategory.Name&lt;br /&gt;&lt;br /&gt;select @MatchingRows = @@ROWCOUNT&lt;br /&gt;&lt;br /&gt;return 0&lt;br /&gt;END TRY&lt;br /&gt;&lt;br /&gt;BEGIN CATCH&lt;br /&gt;&lt;br /&gt;-- LOG THE ERROR … WE MAY WANT TO SKIP THIS STEP WHILE DEBUGGING !&lt;br /&gt;&lt;br /&gt;insert dbo.Application_Error_Log (UserName, errorNumber, errorSeverity, errorState, errorMessage) values (suser_sname(), ERROR_NUMBER(),ERROR_SEVERITY(), ERROR_STATE(), ERROR_MESSAGE())&lt;br /&gt;&lt;br /&gt;SELECT @ErrorNumber = ERROR_NUMBER(), @ErrorString = ERROR_MESSAGE()&lt;br /&gt;&lt;br /&gt;RAISERROR (@ErrorString, 16,1)&lt;br /&gt;&lt;br /&gt;END CATCH&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Where to start debugging the stored procedure&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Before any debugging can take place, you first must create the store procedure. This can be done either by using Management Studio/New Query or by building the procedure graphically in Visual Studio 2005. Stored procedures can be created in Visual Studio by opening a new database project and using the &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/6db0hwky.aspx&quot;&gt;Visual Studio Installed Templates&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;Either way, once the procedure exists, you are ready to start debugging from Visual Studio 2005. When you start up Visual Studio for debugging purposes, you don&#39;t have to create a project. Instead, you can create a connection to the AdventureWorks database from Server Explorer, as I have done in the screenshot shown in Figure 1. (You will have to provide your server name along with your login credentials and choose the AdventureWorks database.) Then you can drill down and open up the stored procedures folder. Next, right click on the procedure you wish to debug and choose Step Into Stored Procedure from the context menu. Then you are ready to start debugging! &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://media.techtarget.com/digitalguide/images/Misc/vs_debug_1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;p&gt;Figure 1: Where to start debugging in VS 2005 &lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to run the stored procedure&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;By stepping into the procedure, you are essentially telling Visual Studio to start running the procedure line by line. Since our sample procedure does accept input parameters, you will see a &lt;strong&gt;Local Window&lt;/strong&gt; that allows you to scroll through the local variables and parameters of the stored procedure. In Figure 2 under the Direction column header, you&#39;ll notice that Visual Studio identifies the output parameters for you, and the Value column is the only column in this window you can change. In this case, I&#39;ve supplied Bike as a CategoryName value. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://media.techtarget.com/digitalguide/images/Misc/vs_debug_2.jpg&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;p&gt;Figure 2: Output parameters &lt;/p&gt;&lt;p&gt;Visual Studio provides numerous windows in which to examine the state of the environment. The line of code waiting to be executed is identified by the yellow arrow in the screenshot in Figure 3. &lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://media.techtarget.com/digitalguide/images/Misc/vs_debug_3.jpg&quot; border=&quot;0&quot; /&gt; Figure 3: Code to be executed &lt;/p&gt;&lt;p&gt;Most of the time, you will Step Into or Step Over commands in your stored procedures. The commands below apply to a single T-SQL line: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Step Into&lt;/strong&gt; (F11): Use to single step through your code. (Move the yellow arrow down one statement.) &lt;/li&gt;&lt;li&gt;&lt;strong&gt;Step Over&lt;/strong&gt; (F10): Useful if you have lines of code that perhaps modify data or call other procedures that you don&#39;t care about while debugging. For example, you may want to skip code that performs auditing. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;Step Out&lt;/strong&gt; (SHIFT-F11): Execute the rest of the stored procedure without pause. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;Run to Cursor&lt;/strong&gt; (CTRL-F10): Position the cursor to a point in your code and then hit CTRL-F10 to execute all code up to that point. &lt;/li&gt;&lt;li&gt;&lt;strong&gt;Continue&lt;/strong&gt; (F5): Resumes execution until completion or until the next breakpoint (more on breakpoints in a minute).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Visual Studio debug windows&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Visual Studio provides us with many informative debug windows. I&#39;ll walk through our sample code to review several of these windows, starting with the Autos window. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The Autos Window&lt;/strong&gt; displays variables used in the current statement. When the yellow arrow points to the select @CategoryName = @CategoryName + &#39;%&#39; line of code, notice the value of @CategoryName is the value prior to the statement actually being executed. In this case, in Figure 4, we have yet to append a percentage to this parameter. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://media.techtarget.com/digitalguide/images/Misc/vs_debug_4.jpg&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;p&gt;Figure 4: Autos window &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The Locals window&lt;/strong&gt; displays the current local variables and parameters and allows you to change the values of these variables interactively during code execution. This window color codes variable values that were changed. In Figure 5 you can see that I changed &quot;Bikes&quot; to &quot;Clothing,&quot; and to identify this Visual Studio, I made this new value red. &lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://media.techtarget.com/digitalguide/images/Misc/vs_debug_5.jpg&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;Figure 5: Locals window &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;The Watch 1 window&lt;/strong&gt; allows you to type or drag from code the T-SQL Expressions to be evaluated in this window and see what the code actually evaluates. This may be useful if you want to investigate the values of expressions contained in conditional expressions, such as IF, WHILE or CASE. You can actually work with up to four watch windows. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The Output window&lt;/strong&gt; displays the result set returned by select or print statements. In our example, we returned 35 matching &quot;Clothing&quot; rows (see Figure 6).&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://media.techtarget.com/digitalguide/images/Misc/vs_debug_6.jpg&quot; border=&quot;0&quot; /&gt; Figure 6: Output window &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The Hovering Value window&lt;/strong&gt; is not really a window, but it&#39;s a great feature worth pointing out. If you hover your cursor over your lines of code while in debug mode, you will see the values of variables associated with that particular line. This seems similar to the Windows application functionality in which you hover your cursor over a toolbar icon without clicking on it to get help. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The Breakpoints window&lt;/strong&gt; displays your current breakpoints and allows you to add them. Breakpoints are user-defined code locations and/or conditions that pause execution, allowing the debugger to reflect, inspect and so on. You can add breakpoints by clicking to the left edge of the code window below, identified by the yellow arrow. Notice that the Breakpoints window in Figure 7 is actually divided into two windows. The lower window provides breakpoint information and tells us there is a breakpoint on line 20. The upper window of Figure 7 contains a code section. In this upper window we do see the red bubble to the left of line 20, which is Visual Studio&#39;s breakpoint indicator.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;http://media.techtarget.com/digitalguide/images/Misc/vs_debug_7.jpg&quot; border=&quot;0&quot; /&gt;Figure 7: Breakpoints window &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Conclusions&lt;br /&gt;&lt;/strong&gt;Visual Studio 2005 has easy-to-use graphical debugging tools for your T-SQL stored procedures. You may want to take advantage of this when unit testing your code. Since developers typically unit test code in the absence of all supporting cast procedures or functions, the Step Over option could really come in handy. Also, since you can easily change values of input parameters or local variables, you can force your program&#39;s flow down paths, which will exercise specific portions of code. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/10/how-to-debug-t-sql-stored-procedures.html</link><author>noreply@blogger.com (Vijay Kumar)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-35664843.post-116097330333296759</guid><pubDate>Mon, 16 Oct 2006 04:34:00 +0000</pubDate><atom:updated>2006-10-15T22:25:25.160-07:00</atom:updated><title>Tuning stored procedures: Structured exception handling in SQL Server 2005</title><description>Exception handling was widely thought to be one of the weakest aspects of T-SQL script writing. Fortunately, this has changed in SQL Server 2005, which supports structured error handling. This tip focuses first on the basics of the new TRY&amp;#46;&amp;#46;&amp;#46;CATCH constructs and then looks at some sample SQL Server 2000 and 2005 T-SQL that produces constraint violations using transactional code. Future tips will continue along this theme.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;TABLE OF CONTENTS&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Exception handling before&lt;/li&gt;&lt;li&gt;Introducing TRY&amp;#46;&amp;#46;&amp;#46;CATCH&lt;/li&gt;&lt;li&gt;Structured vs. unstructured exception handing&lt;/li&gt;&lt;li&gt;SQL Server 2000 exception handling&lt;/li&gt;&lt;li&gt;SQL Server 2005 exception handling&lt;/li&gt;&lt;li&gt;Conclusions&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Exception handling before&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;In previous versions of SQL Server you would handle exceptions by checking the @@error global variable immediately after an INSERT, UPDATE or DELETE, and then perform some corrective action if @@error did not equal zero. Oftentimes, developers would duplicate this unstructured code, which resulted in repetitive blocks of code, and combine it with GOTOs and RETURNs. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Introducing TRY&amp;#46;&amp;#46;&amp;#46;CATCH&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Structured exception handing provides a powerful mechanism for controlling complex programs that have many dynamic runtime characteristics. It is a tried and true practice currently supported by many popular programming languages such as Microsoft Visual Basic .Net and Microsoft Visual C#. You will see in the examples below that utilizing this robust method will make your code more readable and maintainable. The TRY block contains transactional code that could potentially fail, while the CATCH block contains code that executes if an error occurs in the TRY block. If any errors occur in the TRY block, execution is diverted to the CATCH block and the error can be handled while error functions can be used to provide the detailed error information. TRY&amp;#46;&amp;#46;&amp;#46;CATCH has the following abbreviated syntax: &lt;/p&gt;&lt;p&gt;BEGIN TRY&lt;br /&gt;RAISERROR (&#39;Houston, we have a problem&#39;, 16,1)&lt;br /&gt;END TRY&lt;/p&gt;&lt;p&gt;BEGIN CATCH&lt;br /&gt;SELECT ERROR_NUMBER() as ERROR_NUMBER, ERROR_SEVERITY() as ERROR_SEVERITY, ERROR_STATE() as ERROR_STATE, ERROR_MESSAGE() as ERROR_MESSAGE&lt;br /&gt;END CATCH&lt;/p&gt;&lt;p&gt;Notice the use of functions in the script above that we are able to use in place of local and/or global variables. These functions should only be used in a CATCH BLOCK and are explained below: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;ERROR_NUMBER() returns the number of the error&lt;strong&gt;.&lt;/strong&gt; &lt;/li&gt;&lt;li&gt;ERROR_SEVERITY() returns the severity. &lt;/li&gt;&lt;li&gt;ERROR_STATE() returns the error state number. &lt;/li&gt;&lt;li&gt;ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred. &lt;/li&gt;&lt;li&gt;ERROR_LINE() returns the line number inside the routine that caused the error. &lt;/li&gt;&lt;li&gt;ERROR_MESSAGE() returns the complete text of the error message. The text includes the values supplied for any substitutable parameters, such as lengths, object names or times.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I&#39;ll first demonstrate a simple example with SQL Server 2000, followed by an example with SQL Server 2005 exception handling. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Structured vs. unstructured exception handing&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Below is a simple example stored procedure to code using SQL Server 2000 and then 2005. Both procedures start with simple tables that do contain constraints our insert will violate. Here is the table schema: &lt;/p&gt;&lt;p&gt;create table dbo.Titles&lt;br /&gt;(TitleID int Primary Key identity,&lt;br /&gt;TitleName nvarchar(128) NOT NULL,&lt;br /&gt;Price money NULL constraint CHK_Price check (Price &gt; 0))&lt;/p&gt;&lt;p&gt;create table dbo.Authors&lt;br /&gt;(Authors_ID int primary key identity,&lt;br /&gt;au_fname nvarchar(32) NULL,&lt;br /&gt;au_lname nvarchar(64) NULL,&lt;br /&gt;TitleID int constraint FK_TitleID foreign key&lt;br /&gt;references Titles(TitleID),&lt;br /&gt;CommissionRating int constraint CHK_ValidateCommissionRating&lt;br /&gt;Check (CommissionRating between 0 and 100))&lt;/p&gt;&lt;p&gt;create table dbo.Application_Error_Log&lt;br /&gt;(tablename sysname,&lt;br /&gt;userName sysname,&lt;br /&gt;errorNumber int,&lt;br /&gt;errorSeverity int,&lt;br /&gt;errorState int,&lt;br /&gt;errorMessage varchar(4000))&lt;/p&gt;&lt;p&gt;&lt;strong&gt;SQL Server 2000 exception handling&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;As you will see, this stored procedure contains the unstructured error handling we&#39;ve used prior to the arrival to SQL Server 2005. &lt;/p&gt;&lt;p&gt;SQL Server 2005 exception handlingYou&#39;ve seen the code used in P_Insert_New_BookTitle_2K before. The best you can say is, &quot;At least I have exception handling.&quot; The statement below executes the SQL Server 2000 stored procedure. &lt;/p&gt;&lt;p&gt;exec P_Insert_New_BookTitle_2K &#39;Red Storm Rising&#39;,16.99,&#39;Tom&#39;,&#39;Clancy&#39;, 200&lt;/p&gt;&lt;p&gt;When we execute the stored procedure with the provided parameters, the insert into the Authors table fails because of an invalid Commission Rating value. Our check constraint flags this invalid value and we see the following error: &lt;/p&gt;&lt;p&gt;Msg 547, Level 16, State 0, Procedure P_Insert_New_BookTitle, Line 23 The INSERT statement conflicted with the CHECK constraint &quot;CHK_ValidateCommissionRating&quot;. The conflict occurred in database &quot;Adventureworks2005&quot;, table &quot;dbo.Authors&quot;, column &#39;CommissionRating&#39;. The statement has been terminated.&lt;/p&gt;&lt;p&gt;The problem is that we could not stop this message from being sent to the client. So the burden of deciding what went wrong will be placed on the client. Sadly, in some cases, this may be enough for some applications to not use constraints. &lt;/p&gt;&lt;p&gt;Let&#39;s try this again but this time we&#39;ll use the TRY&amp;#46;&amp;#46;&amp;#46;CATCH . &lt;/p&gt;&lt;p&gt;&lt;strong&gt;SQL Server 2005 exception handling&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;In this new and improved procedure we see the TRY&amp;#46;&amp;#46;&amp;#46;CATCH block and structured error handling: &lt;/p&gt;&lt;p&gt;Notice the SQL Server 2005 exception handling code is much more streamlined and, therefore, more readable and maintainable. There&#39;s no cutting and pasting code of exception handling code and no GOTOs. You&#39;ll see the results below when executing this stored procedure: &lt;/p&gt;&lt;p&gt;exec P_Insert_New_BookTitle_2K5 &#39;Red Storm Rising&#39;,16.99,&#39;Tom&#39;,&#39;Clancy&#39;, 200&lt;/p&gt;&lt;p&gt;When we execute the stored procedure with the provided parameters, the insert into the Authors table fails because of an invalid Commission Rating value. When this happens, execution is diverted to the CATCH block, which rolls back our transaction and inserts a row into our Application_Error_Log using the SQL Server 2005 supplied functions. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Conclusions&lt;/strong&gt;&lt;/p&gt;The new TRY&amp;#46;&amp;#46;&amp;#46;CATCH blocks certainly make safe coding easier for handling errors, including stopping error messages from ever making it to the client. While it may require a mind shift for many T-SQL programmers, it&#39;s one feature that was desperately needed. Keep in mind that by migrating your SQL Server 2000 code to 2005, you may have to change your application if was already designed to handle errors that are shipped to the client.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;</description><link>http://dotnetlibrary.blogspot.com/2006/10/tuning-stored-procedures-structured.html</link><author>noreply@blogger.com (Vijay Kumar)</author></item></channel></rss>