<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1117992870719122389</id><updated>2012-02-07T23:17:11.853-08:00</updated><category term='.Net 4.0'/><category term='Scrum Methodology'/><category term='C#.Net'/><category term='OOPS'/><category term='Design Patterns'/><category term='Generic Types'/><category term='Message Queuing'/><category term='ADO.Net'/><category term='.Net'/><title type='text'>Striking with .Net technology</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-7434491399462841515</id><published>2010-02-06T02:54:00.000-08:00</published><updated>2010-02-06T03:00:49.541-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scrum Methodology'/><title type='text'>Scrum Methodology</title><content type='html'>&lt;strong&gt;The Origins of Scrum &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The Scrum software development process is arose from shared concerns between Advanced Development Methods (ADM) and VMARK Software (VMARK). ADM produces process automation software. VMARK produces object-oriented software development environments. Both companies were concerned over the lack of breakthrough productivity being reported in object-oriented development projects. Both ADM's and VMARK's products are built using OO, and breakthrough productivity had been experienced in both companies. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Scrum Empirical Development Process &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The Scrum software development process uses an iterative, incremental approach. Interaction with the environment (technical, competitive, and user) is allowed, which will change the project scope, technology, functionality, cost, and schedule whenever required. Controls are used to measure and manage the impact. &lt;br /&gt;Scrum accepts that the development process is unpredictable. The product is the best possible software, factoring in cost, functionality, timing, and quality. This concept has been discussed by James Bach of Software Testing Laboratories in various articles, including "The Challenge of Good Enough Software". &lt;br /&gt;Scrum formalizes the empirical "do what it takes" software development process used today by many successful ISV's. The empirical approach has been used by these ISV's to cope with the otherwise overwhelming degree of complexity and uncertainty-chaos-in which they develop products. The chaos exists not only in the marketplace where they hope to sell the products, but in the technology that they employ to design and construct these products. &lt;br /&gt;These ISV's succeed and thrive amidst chaos. How? Is their development approach applicable to IS organizations. Is it predictable and controlled? Can it be used in large and small projects? Is it scaleable? Does it work for all types of development? &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Scrum - Characteristics and Rules &lt;/strong&gt;&lt;br /&gt;Scrum encapsulates what works at the best ISV's., Several of the characteristics that guide Microsoft's controlled-chaos approach to the development process are inherent in Scrum : &lt;br /&gt;• "It breaks down large products into manageable chunks - a few product features that small teams can create in a few months. &lt;br /&gt;• It enables project to proceed systematically even when team members cannot determine a complete and stable product design at the project's beginning. &lt;br /&gt;• It allows large teams to work like small teams by dividing work into pieces, proceeding in parallel but synchronizing continuously, stabilizing in increments, and continuously finding and fixing problems. &lt;br /&gt;&lt;br /&gt;It facilitates competition based on customer feedback, product features, and short development times by providing a mechanism to incorporate customer inputs, set &lt;br /&gt;priorities, complete the most important parts first, and change or cut less important features." &lt;br /&gt;Scrum follows common ISV rules : &lt;br /&gt;• Always have a product you can theoretically ship &lt;br /&gt;• Speak a common language on a single development site &lt;br /&gt;• Continuously test the product as you build it &lt;br /&gt;&lt;br /&gt;The key principles the Scrum development process are: &lt;br /&gt;• Small working teams that maximize communication, minimize overhead, and maximize sharing of tacit, informal knowledge &lt;br /&gt;• Adaptability to technical or marketplace (user/customer) changes to ensure the best possible product is produced &lt;br /&gt;• Frequent "builds", or construction of executables, that can be inspected, adjusted, tested, documented, and built on &lt;br /&gt;• Partitioning of work and team assignments into clean, low coupling partitions, or packets &lt;br /&gt;• Constant testing and documentation of a product-as it is built &lt;br /&gt;• Ability to declare a product "done" whenever required (because the competition just shipped, because the company needs the cash, because the user/customer needs the functions, because that was when it was promised...). &lt;br /&gt;&lt;br /&gt;Scrum and empirical development are recommended as enabling processes for developing new software or software that already is object-oriented or has "clean interfaces". Work objects or subsystems with high cohesion and low coupling are grouped into packets. Teams are assigned one or more packets, maximizing a team's ability to work independently. Scrum is applicable for any size project. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The Roles of Scrum&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Scrum has three fundamental roles: Product Owner, ScrumMaster, and team member.&lt;br /&gt;• Product Owner: In Scrum, the Product Owner is responsible for communicating the vision of the product to the development team. He or she must also represent the customer’s interests through requirements and prioritization. Because the Product Owner has the most authority of the three roles, it’s also the role with the most responsibility. In other words, the Product Owner is the single individual who must face the music when a project goes awry. &lt;br /&gt;The tension between authority and responsibility means that it’s hard for Product Owners to strike the right balance of involvement. Because Scrum values self-organization among teams, a Product Owner must fight the urge to micro-manage. At the same time, Product Owners must be available to answer questions from the team.&lt;br /&gt;• ScrumMaster: The ScrumMaster acts as a liaison between the Product Owner and the team. The ScrumMaster does not manage the team. Instead, he or she works to remove any impediments that are obstructing the team from achieving its sprint goals. In short, this role helps the team remain creative and productive, while making sure its successes are visible to the Product Owner. The ScrumMaster also works to advise the Product Owner about how to maximize ROI for the team. &lt;br /&gt;• Team Member: In the Scrum methodology, the team is responsible for completing work. Ideally, teams consist of seven cross-functional members, plus or minus two individuals. For software projects, a typical team includes a mix of software engineers, architects, programmers, analysts, QA experts, testers, and UI designers. Each sprint, the team is responsible for determining how it will accomplish the work to be completed. This grants teams a great deal of autonomy, but, similar to the Product Owner’s situation, that freedom is accompanied by a responsibility to meet the goals of the sprint. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Applicable to Small Simple and Large Complex Software Systems &lt;br /&gt;Prior to Scrum, large complex systems had to be built using either a waterfall or modified waterfall processes. A defined, stepwise approach provided task-level controls for managing the process. However, many of these projects failed because they were unresponsive to changing technology and user requirements, and the adequacy of the deliverables from the tasks couldn't be determined. &lt;br /&gt;A Scrum software project is controlled by establishing, maintaining, and monitoring key measurements as controls. These controls replace task and time-reporting controls used in the waterfall and other defined development processes. These controls are critical when a &lt;br /&gt;software development project is viewed as an empirical process that encompasses an unknown quantity of instability and unpredictability. Use of these controls is the backbone of the Scrum development process. &lt;br /&gt;Through the formalized controls of Scrum, the empirical development process becomes formally scaleable. Using an initial systems architecture and design, work can be partitioned and assigned to as many teams as required and managed at the team and rollup levels. Overall and team risk, workload, problems and other measurements are always known, assessed, and managed. &lt;br /&gt;During the design and system architecture phase of Scrum, the designers and architects divide the project into packets. Packets are assigned to teams based on priority and scheduling constraints. Based on the degree of coupling between packets, groups of up to six teams are organized into a management control cluster. This continues upwards until a top level cluster has been created. &lt;br /&gt;Empirical software development has been used to build systems as large as Windows NT (approximately 4 million lines of C and C++ code)and the Norfolk Southern Railway freight tracking system. Empirical software development has also been used to rapidly get sophisticated, functionally-rich products to market, such as Borland's Quattro Pro for Windows and Advanced Development Method's process management software, MATE ( approximately 4,100 function points). Scrum has also been used for short, simple development projects. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Scrum Productivity &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Compared to other development processes, Scrum delivers. Scrum was compared to other popular development processes by Capers Jones from Software Productivity Group: "Scrum methodology - similar to the iterative methodology, but assumes that all requirements are not known in advance, and that the fastest path to surfacing and implementing all requirements will be discovered empirically during the development process. Careful control mechanisms are used to assure on-time delivery of a high quality product, while allowing maximum flexibility of small, tightly coupled, development teams. Requires a well motivated team and good leadership to implement effectively. Productivity gains of 600% have been seen repeatedly in well executed projects. " &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The Inner Workings of Scrum &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Scrum consists of development processes and measurements that are used to control the development processes. &lt;br /&gt;The key to the success of Scrum is using measurements to maximize flexibility and risk while maintaining control. Most projects try to avoid risk. Yet, risk is an inherent part of software development. Scrum embraces risk by identifying and managing risk-so that the best possible product can be built. &lt;br /&gt;A Scrum software project is controlled by establishing, maintaining, and monitoring key control parameters. These controls are critical when a software development encompasses an unknown quantity of uncertainty, unpredictable behavior, and chaos. Use of these controls is the backbone of the Scrum development process. &lt;br /&gt;The variables in the systems development project are risk, functionality, cost, time, and quality. These variables can be roughly estimated at the start of a project. Each variable will start changing from the moment the project starts. Variables are traded off against each other as the project progresses (improved functionality for later time and more money, etc.). &lt;br /&gt;The controls used in Scrum are: &lt;br /&gt;• Backlog - an identification of all requirements that should be fulfilled in the completed product &lt;br /&gt;• Objects/Components - self-contained reusable things &lt;br /&gt;• Packets - a group of objects within which a backlog item will be implemented. Coupling between the objects in a packet is high. Coupling between packets is low &lt;br /&gt;• Problems - what must be solved by a team member to implement a backlog item within an object(s) (includes bugs) &lt;br /&gt;• Issues - Concerns that must be resolved prior to a backlog item being assigned to a packet or a problem being solved by a change to a packet &lt;br /&gt;• Solutions - the resolution of an issue or problem &lt;br /&gt;• Changes - the activities that are performed to resolve a problem &lt;br /&gt;• Risks - the risk associated with a problem, issue, or backlog item &lt;br /&gt;&lt;br /&gt;These controls are measured, correlated, and tracked. The main controls are backlog and risk. Backlog should start relatively high, get higher during planning, and then be whittled away as the project proceeds - either by being solved or removed, until the software is completed. Risk will rise with the identification of backlog , issues, and problems, and fall to acceptable levels when the software is complete and delivered. &lt;br /&gt;The Scrum methodology consists of three distinct processes. &lt;br /&gt;Planning and System Architecture &lt;br /&gt;Product functionality and estimated delivery requirement are planned based on current backlog and assessed risk. The result of this process is the most optimal, elegant design that meets product performance and architectural requirements. &lt;br /&gt;The definition of a new release is based on currently known and uncovered backlog, along with an estimate of its schedule and cost. If a new system is being developed, conceptualization and analysis are performed. If this project is the next release of an existing system, the analysis is more limited. &lt;br /&gt;A baseline product is established. Changes in the user, customer, competitive, and technological environment will require changes to this baseline definition as the project proceeds. Increased productivity through good tools or uncovered components may open the opportunity for adding more backlog to the product, or for releasing the product earlier. &lt;br /&gt;Backlog and risk management will allow the product release to be planned and managed to optimize the product content and its chance of success - given the environment and resources available. In other words, the very best product possible will be built. Development will occur in a controlled environment, as close to the edge of chaos as possible. &lt;br /&gt;Key is pinning down the date at which the application should be released, prioritizing functionality requirements, identifying resources available for the development effort, envisioning the application architecture, and establishing the target operating environment(s). Compared with other methodologies, the planning phase is conducted relatively quickly because it assumes that pragmatic managers and the course of events will require that these initial parameters will be later changed. &lt;br /&gt;&lt;br /&gt;What differentiates the Scrum Planning and System Architecture process from other methodologies is: &lt;br /&gt;• Controls are established : backlog (requirements) for this project is established and prioritized, risks are defined, objects for implementing backlog are identified, and problems are stated for implementing the backlog into the related objects. &lt;br /&gt;• Team assignments : backlog is assigned to teams of no more than 6 developers, maximizing communication bandwidth and productivity. &lt;br /&gt;• Prioritization : backlog items are prioritized for teams to work on, starting with infrastructure, then most important functionality to least important functionality. &lt;br /&gt;&lt;br /&gt;Sprint (consisting of multiple sprints) &lt;br /&gt;Visualize a large pressure cooker. Scrum development work is done in it. Gauges sticking out of the pressure cooker provide detailed information on the inner workings, including backlog, risks, problems, changes, and issues. The pressure cooker is where Scrum sprints occur, iteratively producing incrementally more functional product. &lt;br /&gt;A sprint is a set of development activities conducted over a pre-defined period resulting in a demonstrable executable. The interval is based on product complexity, risk assessment, and degree of oversight desired. Sprint speed and intensity are driven by the selected duration of the sprint. The duration also depends on where it occurs in the &lt;br /&gt;sequence of sprints (initial sprints are usually given longer duration, later sprints less duration), the degree of control desired, and the level of domain expertise of the various teams. Duration range from one to six weeks &lt;br /&gt;This is where Scrum radically differs from traditional enterprise application methodologies because the planned product (backlog, risk) can be changed at the end of any sprint, in response to the environment (competition, new technology, development tool flaws, etc.). This ensures that the delivered product is a usable product. &lt;br /&gt;Also different, the Sprint phase duration is unknown. The Sprint duration was initially planned-however, as the sprint iterations occur and the product is incrementally developed, the product may be deemed worth delivery at the end of any sprint ... because of market announcements, competitive pressures, or the product is just ready. &lt;br /&gt;The project manager establishes sprint teams consisting of between 1 and 7 members (a fully staffed team should include a developer, quality assurance person, and documentation member). Each sprint consists of one or more teams working on their assigned packets to solve the problems posed for implementing backlog in the objects. Each team is given its assignment(s) and all teams are told to sprint to achieve their objectives on the same day between 1 and 6 weeks from the start of the sprint. However, this process is not as undisciplined as it may seem each team must deliver executable code to successfully end a sprint. &lt;br /&gt;The project remains open to environmental complexity, including competitive, time, quality, and financial pressures, throughout the sprints. The definition of the planned product can be changed during any review meeting of a Sprint. The project and product remain flexible; the delivered product is the best possible and most relevant software possible. &lt;br /&gt;Closure and Consolidation. &lt;br /&gt;When the management team determines that the product is ready for delivery-based on the competition, requirements, cost, and quality-they end the Sprint phase and declare the release "closed". Closure is performed when a build is considered to have reduced risk adequately and resolved and implemented required backlog. &lt;br /&gt;Closure consists of finishing system and regression testing, developing training materials, and completing final documentation. Developed product are prepared for general release. Integration, system test, user documentation, training material preparation, and marketing material preparation are among closure tasks. &lt;br /&gt;The Scrum process asserts that a product is never complete; after the initial construction, it is constantly under development (otherwise known as maintenance and enhancements). Consolidation prepares for the next development cycle. The purpose of consolidation is to clean up the products and artifacts of this development cycle for a clean start on the &lt;br /&gt;next development cycle. This provides an opportunity to clean up all of the loose ends that were let slip during the pressure of getting the release out the door. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Summary &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Scrum produces breakthrough productivity, enabling building the best systems possible in complex, unpredictable environments. &lt;br /&gt;We believe that we have captured the best practices at ISV's in Scrum, making them available to IS organizations. Scrum controls and flexibility puts the teams back in charge.&lt;br /&gt;&lt;strong&gt;References &lt;/strong&gt;&lt;br /&gt;The following sources contain reference material for the subjects of Scrum, "good enough software", and empirical (theoretical) processes. &lt;br /&gt;&lt;strong&gt;WorldWideWeb &lt;/strong&gt;&lt;br /&gt;ADM's home page : http://www.tiac.net/users/virman/ &lt;br /&gt;Jeff Sutherland's page on Scrum : http://www.tiac.net/users/jsuth/scrum/index.html &lt;br /&gt;James Bach's views : http://www.stlabs.com/real_01.htm &lt;br /&gt;http://www.codeproject.com/KB/architecture/scrum.aspx&lt;br /&gt;&lt;strong&gt;Books &lt;/strong&gt;&lt;br /&gt;Cusamo, M. and Selby, R. Microsoft Secrets, The Free Press, 1995 &lt;br /&gt;DeGrace, P. and Hulet-Stahl, L. Wicked Problems, Righteous Solutions. Yourdon Press, 1990 &lt;br /&gt;Gleick, J. Chaos, Making a New Science Penguin Books, 1987 &lt;br /&gt;Ogunnaike, B. Process Dynamics, Modeling, and Control. Oxford University Press, 1994 &lt;br /&gt;Takeuchi, Hirotaka and Nonaka, Ikujiro, The Knowledge-Creating Company : How Japanese Companies Create the Dynamics of Innovation. Oxford University Press, 1995 &lt;br /&gt;&lt;strong&gt;Articles &lt;/strong&gt;&lt;br /&gt;Bach, James. The Challenge of "Good Enough" Software, American Programmer October, 1995 &lt;br /&gt;Curtis, B. A Mature View of the CMM. In American Programmer ,September, 1994 &lt;br /&gt;Racoon, L.B.S. The Chaos Model and the Chaos Life Cycle. In Software Engineering Notes, vol. 20 no. 1, January 1995 &lt;br /&gt;Rumbaugh, J. What Is A Method? In Journal of Object Oriented Programming , October, 1995&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-7434491399462841515?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/7434491399462841515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2010/02/origins-of-scrum-scrum-software.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7434491399462841515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7434491399462841515'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2010/02/origins-of-scrum-scrum-software.html' title='Scrum Methodology'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-6508186530623126123</id><published>2009-07-29T03:22:00.000-07:00</published><updated>2009-07-29T03:23:15.119-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Generic Types'/><title type='text'>C# Constraints on Generic Types</title><content type='html'>C# Constraints on Generic Types&lt;br /&gt;&lt;br /&gt;When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code tries to instantiate your class by using a type that is not allowed by a constraint, the result is a compile-time error. These restrictions are called constraints. Constraints are specified by using the where contextual keyword.&lt;br /&gt;&lt;br /&gt;Why Use Generic Constraints&lt;br /&gt;&lt;br /&gt;If you want to examine an item in a generic list to determine whether it is valid or to compare it to some other item, the compiler must have some guarantee that the operator or method it has to call will be supported by any type argument that might be specified by client code. This guarantee is obtained by applying one or more constraints to your generic class definition. For example, the base class constraint tells the compiler that only objects of this type or derived from this type will be used as type arguments. Once the compiler has this guarantee, it can allow methods of that type to be called in the generic class. Constraints are applied by using the contextual keyword where.&lt;br /&gt;&lt;br /&gt;You can also set up constraints on generic classes. What if you wanted to create a generic list of objects that derived from a certain base class? This would allow you call certain functions that existed in that class.&lt;br /&gt;By constraining the type, you increase the number of functions you can perform on the type.&lt;br /&gt;// File: Constraints.cs&lt;br /&gt;using System;&lt;br /&gt;public class Employee&lt;br /&gt;{&lt;br /&gt;    private string name;&lt;br /&gt;    private int id;&lt;br /&gt;    public Employee(string name, int id)&lt;br /&gt;    {&lt;br /&gt;        this.name = name;&lt;br /&gt;        this.id = id;&lt;br /&gt;    }&lt;br /&gt;    public string Name&lt;br /&gt;    {&lt;br /&gt;        get &lt;br /&gt;        { &lt;br /&gt;            return name; &lt;br /&gt;        }&lt;br /&gt;        set &lt;br /&gt;        {&lt;br /&gt;            name = value; &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    public int Id&lt;br /&gt;    {&lt;br /&gt;        get &lt;br /&gt;        {&lt;br /&gt;            return id; &lt;br /&gt;        }&lt;br /&gt;        set &lt;br /&gt;        {&lt;br /&gt;            id = value; &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;class MyList&lt;T&gt; where T : Employee&lt;br /&gt;{&lt;br /&gt;    T[] list;&lt;br /&gt;    int count;&lt;br /&gt;    public MyList()&lt;br /&gt;    {&lt;br /&gt;        list = new T[10];&lt;br /&gt;        count = 0;&lt;br /&gt;    }&lt;br /&gt;    public void InsertSorted(T t)&lt;br /&gt;    {&lt;br /&gt;        int index = 0;&lt;br /&gt;        bool added = false;&lt;br /&gt;        while (index &lt; count)&lt;br /&gt;        {&lt;br /&gt;            if (list[index].Id &gt; t.Id)&lt;br /&gt;            {&lt;br /&gt;                for (int last = count; last &gt; index; last--)&lt;br /&gt;                {&lt;br /&gt;                    list[last] = list[last - 1];&lt;br /&gt;                }&lt;br /&gt;                list[index] = t;&lt;br /&gt;                added = true;&lt;br /&gt;                break;&lt;br /&gt;            }&lt;br /&gt;            index++;&lt;br /&gt;        }&lt;br /&gt;        if (!added)&lt;br /&gt;        {&lt;br /&gt;            list[index] = t;&lt;br /&gt;        }&lt;br /&gt;        count++;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;class Program&lt;br /&gt;{&lt;br /&gt;    static void Main()&lt;br /&gt;    {&lt;br /&gt;        MyList&lt;Employee&gt; myList = new MyList&lt;Employee&gt;();&lt;br /&gt;        myList.InsertSorted(new Employee("dan", 200));&lt;br /&gt;        myList.InsertSorted(new Employee("sabet", 100));&lt;br /&gt;        myList.InsertSorted(new Employee("mike", 150));&lt;br /&gt;        myList.InsertSorted(new Employee("richard", 120));&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-6508186530623126123?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/6508186530623126123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/07/c-constraints-on-generic-types.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/6508186530623126123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/6508186530623126123'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/07/c-constraints-on-generic-types.html' title='C# Constraints on Generic Types'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-5976174242692041469</id><published>2009-07-24T05:24:00.001-07:00</published><updated>2009-07-24T05:24:44.803-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Design Patterns'/><title type='text'>Abstract Factory Design Pattern</title><content type='html'>Design Patterns:&lt;br /&gt; &lt;br /&gt;Design patterns make it easier to reuse successful designs and architectures. Design patterns help you choose design alternatives that make a system reusable and avoid alternatives that compromise reusability. They help make a system independent of how its objects are created, composed, and represented&lt;br /&gt;&lt;br /&gt;Abstract Design Pattern:&lt;br /&gt;An abstract factory provides an interface for creating families of related objects without specifying their concrete classes.&lt;br /&gt;&lt;br /&gt;Sometimes one wants to construct an instance of one of a suite of classes, deciding between the classes at the time of instantiation. In order to avoid duplicating the decision making everywhere an instance is created, we need a mechanism for creating instances of related classes without necessarily knowing which will be instantiated.&lt;br /&gt;&lt;br /&gt;Create an Abstract Factory class to answer instances of concrete classes (usually subclasses). The class of the resultant instance is unknown to the client of the Abstract Factory. &lt;br /&gt;&lt;br /&gt;There are two types of Abstract Factory: &lt;br /&gt;&lt;br /&gt;Simple Abstract Factory is an abstract class defining Factory methods to answer instances of concrete subclasses. The choice of which subclass to instantiate is completely defined by which method is used, and is unknown to the client. &lt;br /&gt;&lt;br /&gt;The second form of Abstract Factory is an abstract class defining a common protocol of Factory methods. Concrete subclasses of the abstract factory implement this protocol to answer instances of the appropriate suite of classes. &lt;br /&gt;&lt;br /&gt;Need to abstract from details of implementation of products –&lt;br /&gt;&lt;br /&gt;1. The system shall be independent of how its constituent pieces are created, composed, and represented. &lt;br /&gt;2. Need to have multiple families of products - The system shall be configured with one of multiple families of products. &lt;br /&gt;3. Need to enforce families of products that must be used together - A family of related product objects is designed to be used together, and you need to enforce this constraint. &lt;br /&gt;4. Need to hide product implementations and just present interfaces - You want to provide a class library of products, and you want to reveal just their interfaces, not their implementations. &lt;br /&gt;&lt;br /&gt;Characteristics:&lt;br /&gt;&lt;br /&gt;1. An abstract factory is an object maker. &lt;br /&gt;2. It typically can produce more than one type of object. &lt;br /&gt;3. Each object that it produces is known to the receiver of the created object only by that object's interface, not by the object's actual concrete implementation. &lt;br /&gt;4. The different types of objects that the abstract factory can produce are related—they are from a common family. &lt;br /&gt;5. An abstract factory isolates concrete classes. &lt;br /&gt;6. It makes exchanging product families easy. &lt;br /&gt;7. It promotes consistency among products. &lt;br /&gt;8. It supports adding new kinds of products and their families&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;public interface IComputerFactory&lt;br /&gt;    {&lt;br /&gt;        ICPU createCPU();    &lt;br /&gt;        IMemory createMemory();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public interface ICPU&lt;br /&gt;    {&lt;br /&gt;        string GetCPUString();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public interface IMemory&lt;br /&gt;    {&lt;br /&gt;        string GetMemoryString();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    //Concrete CPUA&lt;br /&gt;    public class CPUA : ICPU&lt;br /&gt;    {    &lt;br /&gt;        public string GetCPUString() &lt;br /&gt;        { &lt;br /&gt;            return "CPUA"; &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    //Concrete MemoryA&lt;br /&gt;    public class MemoryA :  IMemory&lt;br /&gt;            {    &lt;br /&gt;        public string GetMemoryString() &lt;br /&gt;        { &lt;br /&gt;            return "MemoryA"; &lt;br /&gt;                &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class ComputerFactoryA : IComputerFactory&lt;br /&gt;    {    &lt;br /&gt;        public ICPU createCPU() &lt;br /&gt;        { &lt;br /&gt;            return new CPUA(); &lt;br /&gt;        }    &lt;br /&gt;        public IMemory createMemory() &lt;br /&gt;        { &lt;br /&gt;            return new MemoryA(); &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    public class Client&lt;br /&gt;    {    &lt;br /&gt;        //this is a template method; does not depend on the Concrete Factory     &lt;br /&gt;        //and the Concrete classes    &lt;br /&gt;        &lt;br /&gt;        public static string BuildComputer(IComputerFactory factory)    &lt;br /&gt;        {        &lt;br /&gt;            ICPU cpu = factory.createCPU();        &lt;br /&gt;            IMemory memory = factory.createMemory(); &lt;br /&gt;            StringBuilder sb = new StringBuilder();&lt;br /&gt;            sb.Append(string.Format("CPU:{0}", cpu.GetCPUString()));&lt;br /&gt;             sb.Append(Environment.NewLine);    &lt;br /&gt;            sb.Append(string.Format("Memory:{0}", &lt;br /&gt;                memory.GetMemoryString()));  &lt;br /&gt;&lt;br /&gt;            return sb.ToString();&lt;br /&gt;            &lt;br /&gt;        }    &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;Calling Client&lt;br /&gt;&lt;br /&gt;private void button2_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Abstract_Factory.IComputerFactory factory= new Abstract_Factory.ComputerFactoryA();&lt;br /&gt;            MessageBox.Show(Abstract_Factory.Client.BuildComputer(factory));&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-5976174242692041469?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/5976174242692041469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/07/abstract-factory-design-pattern.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/5976174242692041469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/5976174242692041469'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/07/abstract-factory-design-pattern.html' title='Abstract Factory Design Pattern'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-8970296411433794837</id><published>2009-07-01T00:16:00.000-07:00</published><updated>2009-07-01T00:18:36.945-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net 4.0'/><title type='text'>Introduction to .Net 4.0</title><content type='html'>In the past programming languages were developed to be either Object oriented or functional. But, today languages were being designed with several paradigms in mind including all best features of programming and functional capabilities.&lt;br /&gt;&lt;br /&gt;The .net languages especially C# is no mere exception to this. The C# language has been witnessing many changes and enhancements in each version to enable the application developers of C# to utilize the real power of programming languages. Ever since, the outburst of the C# language, a .net language in 1998,  with goal of creating a simple, modern, object oriented and type safe language, it has witnessed many enhancements in each release of the .net framework. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The 2.0 version of the language saw the evolution of the support for the following&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1) Generics,&lt;br /&gt;&lt;br /&gt;        2) Anonymous methods, &lt;br /&gt;&lt;br /&gt;        3) Iterators, &lt;br /&gt;&lt;br /&gt;        4) Partial types and &lt;br /&gt;&lt;br /&gt;        5) Nullable types.&lt;br /&gt;&lt;br /&gt;The 3.0 version predominantly concentrated on LINQ (Language Integrated Query) and as a side note to this LINQ, the additional features includes the following to facilitate the former:&lt;br /&gt;&lt;br /&gt;   1) Implictly Typed Local Variables. &lt;br /&gt;&lt;br /&gt;   2) Extension Methods. &lt;br /&gt;&lt;br /&gt;   3) Lambda Expressions. &lt;br /&gt;&lt;br /&gt;   4) Object and Collection Initializers. &lt;br /&gt;&lt;br /&gt;   5) Annonymous types. &lt;br /&gt;&lt;br /&gt;   6) Implicitly Typed Arrays. &lt;br /&gt;&lt;br /&gt;   7) Query Expressions and Expression Trees.&lt;br /&gt;&lt;br /&gt;Coming to the upcoming version of C# which is 4.0 is more inspired by dynamic languages like Perl, Python and Ruby. There are both advantages and disadvantages in using both statical and dynamic languages. Some of the new features that we are going to see in the upcoming release of .net Framework in respect to C# are as described in following sections.&lt;br /&gt;&lt;br /&gt;C# 4.0 language innovations include:&lt;br /&gt;&lt;br /&gt;Dynamically Typed Objects. &lt;br /&gt;Optional and Named Parameters. &lt;br /&gt;Improved COM Interoperability. &lt;br /&gt;Safe Co- and Contra-variance.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;1. Let us consider this simple statically typed .NET class which calls the Add method on that class to get the sum of two integers:&lt;br /&gt;&lt;br /&gt;Calculator calc = GetCalculator();&lt;br /&gt;int sum = calc.Add(10, 20); &lt;br /&gt;&lt;br /&gt;Our code gets all the more interesting if the Calculator class is not statically typed but rather is written in COM, Ruby, Python, or even JavaScript. Even if we knew that the Calculator class is a .NET object but we don't know specifically which type it is then we would have to use reflection to discover attributes about the type at runtime and then dynamically invoke the Add method.&lt;br /&gt;&lt;br /&gt;object calc = GetCalculator();&lt;br /&gt;Type type = calc.GetType();&lt;br /&gt;object result = type.InvokeMember("Add",&lt;br /&gt;                                  BindingFlags.InvokeMethod, null,&lt;br /&gt;                                  new object[] { 10, 20 });&lt;br /&gt;int sum = Convert.ToInt32(result);&lt;br /&gt;&lt;br /&gt;If the Calculator class was written in JavaScript then our code would look somewhat like the following.&lt;br /&gt;&lt;br /&gt;ScriptObect calc = GetCalculator();&lt;br /&gt;object result = calc.InvokeMember("Add", 10, 20);&lt;br /&gt;int sum = Convert.ToInt32(result);&lt;br /&gt;&lt;br /&gt;With the C# 4.0 we would simply write the following code:&lt;br /&gt;&lt;br /&gt;dynamic calc = GetCalculator();&lt;br /&gt;int result = calc.Add(10, 20);&lt;br /&gt;&lt;br /&gt;In the above example we are declaring a variable, calc, whose static type is dynamic. Yes, you read that correctly, we've statically typed our object to be dynamic. We'll then be using dynamic method invocation to call the Add method and then dynamic conversion to convert the result of the dynamic invocation to a statically typed integer.&lt;br /&gt;&lt;br /&gt;You're still encouraged to use static typing wherever possible because of the benefits that statically typed languages afford us. Using C# 4.0 however, it should be less painful on those occassions when you have to interact with dynamically typed objects.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Another major benefit of using C# 4.0 is that the language now supports optional and named parameters and so we'll now take a look at how this feature will change the way you design and write your code.&lt;br /&gt;&lt;br /&gt;One design pattern you'll often see as that a particular method is overloaded because the method needs to be called with a variable number of parameters.&lt;br /&gt;&lt;br /&gt;Let's assume that we have the following OpenTextFile method along with three overloads of the method with different signatures. Overloads of the primary method then call the primary method passing default values in place of those parameters for which a value was not specified within the call to the overloaded method.&lt;br /&gt;&lt;br /&gt;public StreamReader OpenTextFile(&lt;br /&gt;         string path,&lt;br /&gt;         Encoding encoding,&lt;br /&gt;         bool detectEncoding,&lt;br /&gt;         int bufferSize) { }&lt;br /&gt;&lt;br /&gt;public StreamReader OpenTextFile(&lt;br /&gt;         string path,&lt;br /&gt;         Encoding encoding,&lt;br /&gt;         bool detectEncoding) { }&lt;br /&gt;&lt;br /&gt;public StreamReader OpenTextFile(&lt;br /&gt;         string path,&lt;br /&gt;         Encoding encoding) { }&lt;br /&gt;&lt;br /&gt;public StreamReader OpenTextFile(string path) { }&lt;br /&gt;&lt;br /&gt;In C# 4.0 the primary method can be refactored to use optional parameters as the following example shows:&lt;br /&gt;&lt;br /&gt;public StreamReader OpenTextFile(&lt;br /&gt;         string path,&lt;br /&gt;         Encoding encoding = null,&lt;br /&gt;         bool detectEncoding = false,&lt;br /&gt;         int bufferSize = 1024) { }&lt;br /&gt;&lt;br /&gt;Given this declaration it is now possible to call the OpenTextFile method omitting one or more of the optional parameters.&lt;br /&gt;&lt;br /&gt;OpenTextFile("foo.txt", Encoding.UTF8);&lt;br /&gt;&lt;br /&gt;It is also possible to use the C# 4.0 support for named parameters and as such the OpenTextFile method can be called omitting one or more of the optional parameters while also specifying another parameter by name.&lt;br /&gt;&lt;br /&gt;OpenTextFile("foo.txt", Encoding.UTF8, bufferSize: 4098);&lt;br /&gt;&lt;br /&gt;Named arguments must be provided last although when provided they can be provided in any order.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. If you have ever written any code that performs some degree of COM interoperability you have probably seen code such as the following.&lt;br /&gt;&lt;br /&gt;object filename = "test.docx";&lt;br /&gt;object missing = System.Reflection.Missing.Value;&lt;br /&gt;doc.SaveAs(ref filename,&lt;br /&gt;           ref missing, ref missing, ref missing,&lt;br /&gt;           ref missing, ref missing, ref missing,&lt;br /&gt;           ref missing, ref missing, ref missing,&lt;br /&gt;           ref missing, ref missing, ref missing,&lt;br /&gt;           ref missing, ref missing, ref missing);&lt;br /&gt;&lt;br /&gt;With optional and named parameters the C# 4.0 language provides significant improvements in COM interoperability and so the above code can now be refactored such that the call is merely:&lt;br /&gt;&lt;br /&gt;doc.SaveAs("foo.txt");&lt;br /&gt;&lt;br /&gt;When performing COM interoperability you'll notice that you are able to omit the ref modifer although the use of the ref modifier is still required when not performing COM interoperability.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;With previous versions of the technologies it was necessary to also ship a Primary Interop Assembly (PIA) along with your managed application. This is not necessary when using C# 4.0 because the compiler will instead inject the interop types directly into the assemblies of your managed application and will only inject those types you're using and not all of the types found within the PIA.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. The final language improvement that we will explore is co-variance and contra-variance and we'll begin by exploring co-variance with .NET arrays.&lt;br /&gt;&lt;br /&gt;string[] names = new string[] {&lt;br /&gt;                     "Anders Hejlsberg",&lt;br /&gt;                     "Mads Torgersen",&lt;br /&gt;                     "Scott Wiltamuth",&lt;br /&gt;                     "Peter Golde" };&lt;br /&gt;&lt;br /&gt;Write(names);&lt;br /&gt;&lt;br /&gt;Since version 1.0 an array in the .NET Framework has been co-variant meaning that an array of strings, for example, can be passed to a method that expects an array of objects. As such the above array can be passed to the following Write method which expects an array of objects.&lt;br /&gt;&lt;br /&gt;private void Write(object[] objects)&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Unfortunately arrays in .NET are not safely co-variant as we can see in the following code. Assuming that the objects variable is an array of strings the following will succeed.&lt;br /&gt;&lt;br /&gt;objects[0] = "Hello World";&lt;br /&gt;&lt;br /&gt;Although if an attempt is made to assign an integer to the array of strings an ArrayTypeMismatchException is thrown.&lt;br /&gt;&lt;br /&gt;objects[0] = 1024;&lt;br /&gt;&lt;br /&gt;In both C# 2.0 and C# 3.0 generics are invariant and so a compiler error would result from the following code:&lt;br /&gt;&lt;br /&gt;List&lt;string&gt; names = new List&lt;string&gt;();&lt;br /&gt;&lt;br /&gt;Write(names);&lt;br /&gt;&lt;br /&gt;Where the Write method is defined as:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Generics with C# 4.0 now support safe co-variance and contra-variance through the use of the in and out contextual keywords. Let's take a look at how this changes the definition of the IEnumerable&lt;T&gt; and IEnumerator&lt;T&gt; interfaces.&lt;br /&gt;&lt;br /&gt;public interface IEnumerable&lt;out T&gt;&lt;br /&gt;{&lt;br /&gt;    IEnumerator&lt;T&gt; GetEnumerator();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public interface IEnumerator&lt;out T&gt;&lt;br /&gt;{&lt;br /&gt;    T Current { get; }&lt;br /&gt;    bool MoveNext();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;You'll notice that the type parameter T of the IEnumerable interface has been prefixed with the out contextual keyword. Given that the IEnumerable interface is read only, there is no ability specified within the interface to insert new elements with the list, it is safe to treat something more derived as something less derived. With the out contextual keyword we are contractually affirming that IEnumerable&lt;out T&gt; is safely co-variant. Given that IEnumerable&lt;out T&gt; is safely co-variant we can now write the following code:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Because the IEnumerable&lt;out T&gt; interface uses the out contextual keyword the compiler can reason that the above assignment is safe.&lt;br /&gt;&lt;br /&gt;Using the in contextual keyword we can achieve safe contra-variance, that is treating something less derived as something more derived.&lt;br /&gt;&lt;br /&gt;public interface IComparer&lt;in T&gt;&lt;br /&gt;{&lt;br /&gt;    int Compare(T x, T y);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Given that IComparer&lt;in T&gt; is safely contra-variant we can now write the following code:&lt;br /&gt;&lt;br /&gt;IComparer[object] objectComparer = GetComparer();&lt;br /&gt;IComparer[string] stringComparer = objectComparer;&lt;br /&gt;&lt;br /&gt;Although the current CTP build of Visual Studio 2010 and the .NET Framework 4.0 has limited support for the variance improvements in C# 4.0 the forthcoming beta will allow you to use the new in and out contextual keywords in types such as IComparer&lt;in T&gt;. The .NET Framework team is updating the types within the framework to be safely co- and contra-variant.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-8970296411433794837?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/8970296411433794837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/07/introduction-to-net-40.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8970296411433794837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8970296411433794837'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/07/introduction-to-net-40.html' title='Introduction to .Net 4.0'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-8768099308819110247</id><published>2009-06-19T04:45:00.000-07:00</published><updated>2009-06-19T04:51:47.551-07:00</updated><title type='text'>How to make window services in .Net</title><content type='html'>How to make window services in .Net&lt;br /&gt;&lt;br /&gt;Definition: Microsoft Windows services enable you to create long-running executable applications that run in their own Windows sessions. These services (e.g. SQL server Service) can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. Whenever you need long-running functionality that does not interfere with other users who are working on the same computer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We can start, stop, or pause a Windows service from the Windows Services management console. This MMC (Microsoft Management Console) can be opened by selecting the group from the Administrative Tools programs group. All the services currently running on our system.&lt;br /&gt;&lt;br /&gt;Windows Services in DOTNET&lt;br /&gt;To make a Windows service, we need three types of operational programs. They are as follows:&lt;br /&gt;• Service Program &lt;br /&gt;• Service Control Program &lt;br /&gt;• Service Configuration program &lt;br /&gt;Service Program&lt;br /&gt;A Service Program is the main program where our code resides. Here, we write the actual logic for our service. One point to note here is that each service program can refer to more than one service but each one of these services must contain their own entry point or a Main() method. This Main() method is just like the Main() method in C#.&lt;br /&gt;To write a service class, we need to inherit it from a ServiceBase class. The ServiceBase class is a part of the System.ServiceProcess class.&lt;br /&gt;Service Control Program&lt;br /&gt;A service control program is a part of the operating system. It is responsible for the starting, stopping, and pausing of a Windows service. To implement a Windows service, we need to inherit from the ServiceController class of the System.ServiceProcess class.&lt;br /&gt;Service Configuration Program&lt;br /&gt;Once a service is made, it needs to be installed and configured. Configuration involves that this service will be started manually or at boot time. To implement a service program, we need to inherit from the ServiceProcessInstaller class of ServiceInstaller.&lt;br /&gt;&lt;br /&gt;To create a new Windows service, select a Windows service project. Type a project name and click OK. VS.NET will create the basic code for us. We will just have to write the logic of the code. &lt;br /&gt;There is one important thing to consider in the Main() method:&lt;br /&gt;Program.cs&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.ServiceProcess;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;namespace MonitoringService&lt;br /&gt;{&lt;br /&gt;    static class Program&lt;br /&gt;    {&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// The main entry point for the application.&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        static void Main()&lt;br /&gt;        {&lt;br /&gt;            ServiceBase[] ServicesToRun = new ServiceBase[] &lt;br /&gt;                                              { &lt;br /&gt;                                                  new MonitoringWinService() &lt;br /&gt;                                              };&lt;br /&gt;            ServiceBase.Run(ServicesToRun);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MonitoringService.config&lt;br /&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt;  &lt;appSettings&gt;&lt;br /&gt;    &lt;add key="WinService_log" value="C:\MonitoringService_LogFile.log"/&gt;&lt;br /&gt;    &lt;add key="FolderPath" value="\\Image_Server\Project SRLMatics\Process\Data\Image_Folder\"/&gt;&lt;br /&gt;  &lt;/appSettings&gt;&lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MonitoringWinService.cs&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.ServiceProcess;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;namespace MonitoringService&lt;br /&gt;{&lt;br /&gt;    public partial class MonitoringWinService : ServiceBase&lt;br /&gt;    {&lt;br /&gt;        readonly EventLog eventLog1 = new EventLog();&lt;br /&gt;               &lt;br /&gt;        readonly System.Timers.Timer timer1 = new System.Timers.Timer();&lt;br /&gt;        &lt;br /&gt;        public MonitoringWinService()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            timer1.Enabled = true;&lt;br /&gt;            timer1.Start();&lt;br /&gt;            timer1.Interval= 60000; // One Minute&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;            if(!System.Diagnostics.EventLog.SourceExists("MonitoringWinService"))&lt;br /&gt;            System.Diagnostics.EventLog.CreateEventSource("MonitoringWinService",&lt;br /&gt;                                                          "MonitoringWinService_Logging");&lt;br /&gt;&lt;br /&gt;    eventLog1.Source = "MonitoringWinService";&lt;br /&gt;    &lt;br /&gt;    eventLog1.Log = "MonitoringWinService_Logging";&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #region Properties&lt;br /&gt;&lt;br /&gt;        private string _MonitoringFolder = string.Empty;&lt;br /&gt;        public string MonitoringFolder&lt;br /&gt;        {&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                if(!string.IsNullOrEmpty(ConfigurationSettings.AppSettings["FolderPath"].ToString()))&lt;br /&gt;                {&lt;br /&gt;                    _MonitoringFolder = mCheckFolderPath(ConfigurationSettings.AppSettings["FolderPath"].ToString());&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    _MonitoringFolder = @"c:\Image_Folder\"; // Default Value&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _MonitoringFolder;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private string _LogFile = string.Empty;&lt;br /&gt;        public string LogFile&lt;br /&gt;        {&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                if(!string.IsNullOrEmpty(ConfigurationSettings.AppSettings["WinService_log"].ToString()))&lt;br /&gt;                {&lt;br /&gt;                    _LogFile = ConfigurationSettings.AppSettings["WinService_log"].ToString();&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    _LogFile = @"C:\MonitoringService_LogFile.log"; // Default Value&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _LogFile;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;#endregion&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        #region CustomMethods&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// For Monitoring Folder Size&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="strDirectory"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public int mGetDirectoryLength(string strDirectory)&lt;br /&gt;        {&lt;br /&gt;            long iTotalSize = 0;&lt;br /&gt;            List&lt;string&gt; list = new List&lt;string&gt;();&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                foreach (string d in Directory.GetFiles(strDirectory))&lt;br /&gt;                {&lt;br /&gt;                    iTotalSize = iTotalSize + mGetFileLength(d);&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                return mConvertBytesIntoGB(iTotalSize);&lt;br /&gt;            }&lt;br /&gt;            catch (System.Exception excpt)&lt;br /&gt;            {&lt;br /&gt;                return 0;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Convert Bytes into MB&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="bytes"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public int mConvertBytesIntoMB(long bytes)&lt;br /&gt;        {&lt;br /&gt;            return Convert.ToInt32(Math.Round(bytes / 1024.0 / 1024.0, 2));&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Convert Bytes into GB&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="bytes"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public int mConvertBytesIntoGB(long bytes)&lt;br /&gt;        {&lt;br /&gt;            return Convert.ToInt32(Math.Round(bytes / 1024.0 / 1024.0 / 1024.0, 2));&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Get File Length of the File&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="strFilePath"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public long mGetFileLength(string strFilePath)&lt;br /&gt;        {&lt;br /&gt;            if (!string.IsNullOrEmpty(strFilePath))&lt;br /&gt;            {&lt;br /&gt;                FileInfo info = new System.IO.FileInfo(strFilePath);&lt;br /&gt;                return info.Length;&lt;br /&gt;            }&lt;br /&gt;            return 0;&lt;br /&gt;        }&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// To Check the Folder Path.&lt;br /&gt;        /// Adding slash at end to make it valid path&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="strpath"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public static string mCheckFolderPath(string strpath)&lt;br /&gt;        {&lt;br /&gt;            if(!string.IsNullOrEmpty(strpath))&lt;br /&gt;            {&lt;br /&gt;                if(strpath.Substring((strpath.Length-1), 1)!=@"\")&lt;br /&gt;                {&lt;br /&gt;                    return  strpath.Insert(strpath.Length, @"\");&lt;br /&gt;                    &lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                return strpath;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return strpath;&lt;br /&gt;        }&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Log-Writer&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="LogMessage"&gt;&lt;/param&gt;&lt;br /&gt;        public void mWriteLogFile(string LogMessage)&lt;br /&gt;        {&lt;br /&gt;            if (LogMessage == null) throw new ArgumentNullException("LogMessage");&lt;br /&gt;            if (!File.Exists(LogFile))&lt;br /&gt;                File.Create(LogFile);&lt;br /&gt;&lt;br /&gt;            FileStream fs = new FileStream(LogFile, FileMode.Open, FileAccess.Write);&lt;br /&gt;&lt;br /&gt;            StreamWriter writer = new StreamWriter(fs, ASCIIEncoding.Default);&lt;br /&gt;&lt;br /&gt;            writer.WriteLine(LogMessage);&lt;br /&gt;            writer.Flush();&lt;br /&gt;            writer.Close();&lt;br /&gt;&lt;br /&gt;            fs.Close();&lt;br /&gt;                        &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        protected override void OnStart(string[] args)&lt;br /&gt;        {&lt;br /&gt;            mWriteLogFile("Service Started ............." + DateTime.Now);&lt;br /&gt;            eventLog1.WriteEntry("Service Started " + DateTime.Now); &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void OnStop()&lt;br /&gt;        {&lt;br /&gt;            mWriteLogFile("Service Stopped ............." + DateTime.Now);&lt;br /&gt;            eventLog1.WriteEntry("Service Stopped " + DateTime.Now); &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void OnContinue()&lt;br /&gt;        {&lt;br /&gt;            mWriteLogFile("Image_Folder monitoring in Process " + DateTime.Now);&lt;br /&gt;            eventLog1.WriteEntry("Image_Folder monitoring in Process " + DateTime.Now); &lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void timer1_Tick(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            mWriteLogFile(string.Format("Folder Size [GB] {0} - DateTime {1}", mGetDirectoryLength(MonitoringFolder).ToString(), DateTime.Now.ToString()));&lt;br /&gt;            eventLog1.WriteEntry(string.Format("Folder Size [GB]{0} - DateTime {1}", mGetDirectoryLength(MonitoringFolder).ToString(), DateTime.Now.ToString()));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;InstallerClass.cs&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.ServiceProcess;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;namespace MonitoringService&lt;br /&gt;{&lt;br /&gt;[RunInstallerAttribute(true)]&lt;br /&gt;public class InstallerClass : System.Configuration.Install.Installer&lt;br /&gt;{&lt;br /&gt;public InstallerClass()&lt;br /&gt;{&lt;br /&gt;ServiceInstaller si = new ServiceInstaller();&lt;br /&gt;ServiceProcessInstaller spi = new ServiceProcessInstaller();&lt;br /&gt;&lt;br /&gt;si.ServiceName = "MonitoringImageFolder";&lt;br /&gt;si.DisplayName = "MonitoringImageFolder";&lt;br /&gt;si.StartType = ServiceStartMode.Automatic;&lt;br /&gt;this.Installers.Add(si);&lt;br /&gt;&lt;br /&gt;spi.Account = System.ServiceProcess.ServiceAccount.LocalSystem;&lt;br /&gt;spi.Username=null;&lt;br /&gt;spi.Password=null;&lt;br /&gt;this.Installers.Add(spi);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Deployment Process&lt;br /&gt;To add a deployment project&lt;br /&gt;1. On the File menu, point to Add, and then click New Project.&lt;br /&gt;2. In the Add New Project dialog box's Project Type pane, open the Other Project Types node, select Setup and Deployment Projects. In the Templates pane, choose Setup Project. In the Name box, type MonitoringService_Setup.&lt;br /&gt;The project is added to Solution Explorer and the File System Editor is displayed.&lt;br /&gt;3. In the File System Editor, select Application Folder in the left pane. On the Action menu, point to Add, and then choose Project Output.&lt;br /&gt;4. In the Add Project Output Group dialog box, OpenWeb3 will be displayed in the Project list. Select Primary Output.&lt;br /&gt;Primary Output from OpenWeb (Active) appears in the Application Folder.&lt;br /&gt;To add the custom action&lt;br /&gt;1. Select the MonitoringService_Setup project in Solution Explorer. On the View menu, point to Editor, and then choose Custom Actions.&lt;br /&gt;The Custom Actions Editor is displayed.&lt;br /&gt;2. In the Custom Actions Editor, select the Commit node. On the Action menu, choose Add Custom Action.&lt;br /&gt;3. In the Select Item in Project dialog box, double-click the Application Folder. Then select Primary output from MonitoringService.&lt;br /&gt;Primary output from MonitoringService appears under the Commit node in the Custom Actions Editor.&lt;br /&gt;4. In the Properties window, make sure that the InstallerClass property is set to True (this is the default).&lt;br /&gt;5. In the Custom Actions Editor, select the Install node and add Primary output from MonitoringService to this node as you did for the Commit node.&lt;br /&gt;6. On the Build menu, choose MonitoringService_Setup.&lt;br /&gt; InstallUtil could also be use to Install the Windows Service &lt;br /&gt;Open a Visual Studio .NET Command Prompt &lt;br /&gt;Change to the bin\Debug directory of your project location (bin\Release if you compiled in release mode) &lt;br /&gt;Issue the command InstallUtil.exe MonitoringService.exe to register the service and have it create the appropriate registry entries &lt;br /&gt;Open the Computer Management console by right clicking on My Computer on the desktop and selecting Manage &lt;br /&gt;In the Services section underneath Services and Applications you should now see your Windows Service included in the list of services &lt;br /&gt;Start your service by right clicking on it and selecting Start &lt;br /&gt;Each time you need to change your Windows Service it will require you to uninstall and reinstall the service. Prior to uninstalling the service it is a good idea to make sure you have the Services management console closed. If you do not you may have difficulty uninstalling and reinstalling the Windows Service. To uninstall the service simply reissue the same InstallUtil command used to register the service and add the /u command switch&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-8768099308819110247?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/8768099308819110247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/06/how-to-make-window-services-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8768099308819110247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8768099308819110247'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/06/how-to-make-window-services-in-net.html' title='How to make window services in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-7487990510750078914</id><published>2009-06-08T00:12:00.001-07:00</published><updated>2009-06-09T02:49:27.647-07:00</updated><title type='text'>What is SilverLight</title><content type='html'>What is Silverlight?&lt;br /&gt;&lt;br /&gt;Silverlight is a new cross-browser, cross-platform implementation of the .NET Framework for building and delivering the next generation of media experiences and Rich Interactive Applications(RIA) for the web. It runs in all popular browsers, including Microsoft Internet Explorer, Mozilla Firefox, Apple Safari, Opera. The plugin required to run Silverlight is very small in size hence gets installed very quickly.&lt;br /&gt;It is combination of different technolgoies into a single development platform that allows you to select tools and the programming language you want to use. Silverlight integrates seamlessly with your existing Javascript and ASP.NET AJAX code to complement functionality which you have already created.&lt;br /&gt;Silverlight aims to compete with Adobe Flash and the presentation components of Ajax. It also competes with Sun Microsystems' JavaFX, which was launched a few days after Silverlight.&lt;br /&gt;Currently there are 2 versions of Silverlight:&lt;br /&gt;&lt;br /&gt;Silverlight 1.0 : &lt;br /&gt;&lt;br /&gt;Silverlight 1.0 consists of the core presentation framework, which is responsible for UI, interactivity and user input, basic UI controls, graphics and animation, media playback, DRM support, and DOM integration.&lt;br /&gt;Main features of Silverlight 1.0 : &lt;br /&gt;1. Built-in codec support for playing VC-1 and WMV video, and MP3 and WMA audio within a browser. &lt;br /&gt;2. Silverlight supports the ability to progressively download and play media content from any web-server. &lt;br /&gt;3. Silverlight also optionally supports built-in media streaming. &lt;br /&gt;4. Silverlight enables you to create rich UI and animations, and blend vector graphics with HTML to create compelling content experiences. &lt;br /&gt;5. Silverlight makes it easy to build rich video player interactive experiences. &lt;br /&gt;&lt;br /&gt;Silverlight 1.1 : &lt;br /&gt;&lt;br /&gt;Silverlight 1.1 includes a version of the .NET Framework, with the full Common Language Runtime as .NET Framework 3.0; so it can execute any .NET language including VB.NET and C# code. Unlike the CLR included with .NET Framework, multiple instances of the CoreCLR included in Silverlight can be hosted in one process.[16] With this, the XAML layout markup file (.xaml file) can be augmented by code-behind code, written in any .NET language, which contains the programming logic.&lt;br /&gt;Main features of Silverlight 1.1 : &lt;br /&gt;1. A built-in CLR engine that delivers a super high performance execution environment for the browser. Silverlight uses the same core CLR engine that we ship with the full .NET Framework. &lt;br /&gt;2. Silverlight includes a rich framework library of built-in classes that you can use to develop browser-based applications. &lt;br /&gt;3. Silverlight includes support for a WPF UI programming model. The Silverlight 1.1 Alpha enables you to program your UI with managed code/event handlers, and supports the ability to define and use encapsulated UI controls. &lt;br /&gt;4. Silverlight provides a managed HTML DOM API that enables you to program the HTML of a browser using any .NET language. &lt;br /&gt;5. Silverlight doesn't require ASP.NET to be used on the backend web-server (meaning you could use Silverlight with with PHP on Linux if you wanted to). &lt;br /&gt;How Silverlight would change the Web:&lt;br /&gt;1. Highest Quality Video Experience : prepare to see some of the best quality videos you have seen in your life, all embedded in highly graphical websites. The same research and technology that was used for VC-1, the codec that powers BluRay and HD DVD, is used by Microsoft today with its streaming media technologies. &lt;br /&gt;2. Cross-Platform, Cross-Browser : Finally build web applications that work on any browser, and on any operating system. At release, Silverlight will work with Mac as well as Windows!  The Mono project has also already promised support for Linux!. &lt;br /&gt;3. Developers and Graphic Designers can play together! : Developers familiar with Visual Studio, Microsoft.net will be able to develop amazing Silverlight applications very quickly, and they will work on Mac's and Windows. Developers will finally be able to strictly focus on the back end of the application core, while leaving the visuals to the Graphic Design team using the power of XAML. &lt;br /&gt;4. Cheaper : Silverlight is now the most inexpensive way to stream video files over the internet at the best quality possible. Licensing is dead simple, all you need is IIS in Windows Server, and you’re done. &lt;br /&gt;5. Support for 3rd Party Languages : Using the power of the new Dynamic Language Runtime, developers will now be able to use Ruby, Python, and EcmaScript! This means a Ruby developer can develop Silverlight applications, and leverage the .net Framework! &lt;br /&gt;6. Cross-Platform, Cross-Browser Remote Debugging : If you are in the need to debug an application running on a Mac, no problem! You can now set breakpoints, step into/over code, have immediate windows, and all that other good stuff that Visual Studio provides. &lt;br /&gt;7. The best development environment on the planet : Visual Studio is an award winning development platform! As it continues to constantly evolve, so will Silverlight! &lt;br /&gt;8. Silverlight offers copy protection : Have you noticed how easy it is to download YouTube videos to your computer, and save them for later viewing ? Silverlight will finally have the features enabling content providers complete control over their rich media content! Streaming television, new indie broadcast stations, all will now be possible! &lt;br /&gt;9. Extreme Speed :There is a dramatic improvement in speed for AJAX-enabled websites that begin to use Silverlight, leveraging the Microsoft .net framework. &lt;br /&gt;Getting Started With SilverLight :&lt;br /&gt;In order to create Silverlight applications with following :&lt;br /&gt;Runtime : &lt;br /&gt;Microsoft Silverlight 1.1 (currently alpha) : The runtime required to view Silverlight applications created with .NET Microsoft.&lt;br /&gt;Developer Tools : &lt;br /&gt;Microsoft Visual Studio codename "Orcas" (currently Beta 1) : The next generation development tool.&lt;br /&gt;Microsoft Silverlight Tools Alpha for Visual Studio codename "Orcas" : The add-on to create Silverlight applications using .NET.&lt;br /&gt;Designer Tools :&lt;br /&gt;Download the Expression designer tools to start designing Silverlight application.&lt;br /&gt;Expression Blend 2 &lt;br /&gt;Software Development Kit:&lt;br /&gt;Microsoft Silverlight 1.1 Alpha Software Development Kit (SDK) : Download this SDK to create Silverlight Web experiences that target Silverlight 1.1 Alpha. The SDK contains documentation and samples.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-7487990510750078914?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/7487990510750078914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/06/what-is-silverlight_08.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7487990510750078914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7487990510750078914'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/06/what-is-silverlight_08.html' title='What is SilverLight'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-3104227636478011022</id><published>2009-05-28T03:02:00.000-07:00</published><updated>2009-05-28T03:04:16.388-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.Net'/><title type='text'>OracleHelper.cs</title><content type='html'>&lt;em&gt;&lt;strong&gt;This OracleHelper class is intended to encapsulate high performance, scalable best practices for common uses of OracleClient&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data.OracleClient;&lt;br /&gt;using System.Data;&lt;br /&gt;&lt;br /&gt;namespace Trans829115.DAL&lt;br /&gt;{&lt;br /&gt;    public class OracleHelper&lt;br /&gt;    {&lt;br /&gt;        private string strConnectionString;&lt;br /&gt;        private OracleConnection oConnection;&lt;br /&gt;        private OracleCommand oCommand;&lt;br /&gt;        private int iTimeOut = 30;&lt;br /&gt;&lt;br /&gt;        public enum ExpectedType &lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            StringType = 0,&lt;br /&gt;            NumberType = 1,&lt;br /&gt;            DateType = 2,&lt;br /&gt;            BooleanType = 3,&lt;br /&gt;            ImageType = 4&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public OracleHelper()&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                strConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();&lt;br /&gt;&lt;br /&gt;                oConnection = new OracleConnection(strConnectionString);&lt;br /&gt;                oCommand = new OracleCommand();&lt;br /&gt;                oCommand.CommandTimeout = iTimeOut;&lt;br /&gt;                oCommand.Connection = oConnection;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw new Exception("Error initializing OracleHelper class." + Environment.NewLine + ex.Message);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public OracleHelper(string MyConnectionString)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                strConnectionString = MyConnectionString;&lt;br /&gt;&lt;br /&gt;                oConnection = new OracleConnection(strConnectionString);&lt;br /&gt;                oCommand = new OracleCommand();&lt;br /&gt;                oCommand.CommandTimeout = iTimeOut;&lt;br /&gt;                oCommand.Connection = oConnection;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw new Exception("Error initializing OracleHelper class." + Environment.NewLine + ex.Message);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void Dispose()&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                //Dispose off connection object&lt;br /&gt;                if (oConnection != null)&lt;br /&gt;                {&lt;br /&gt;                    if (oConnection.State != ConnectionState.Closed)&lt;br /&gt;                    {&lt;br /&gt;                        oConnection.Close();&lt;br /&gt;                    }&lt;br /&gt;                    oConnection.Dispose();&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                //Clean Up Command Object&lt;br /&gt;                if (oCommand != null)&lt;br /&gt;                {&lt;br /&gt;                    oCommand.Dispose();&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw new Exception("Error disposing OracleHelper class." + Environment.NewLine + ex.Message);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void CloseConnection()&lt;br /&gt;        {&lt;br /&gt;            if (oConnection.State != ConnectionState.Closed) oConnection.Close();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public int GetExecuteScalarByCommand(string Command)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            object identity = 0;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.CommandText = Command;&lt;br /&gt;                oCommand.CommandTimeout = iTimeOut;&lt;br /&gt;                oCommand.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;                oConnection.Open();&lt;br /&gt;&lt;br /&gt;                oCommand.Connection = oConnection;&lt;br /&gt;                identity = oCommand.ExecuteScalar();&lt;br /&gt;                CloseConnection();&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                CloseConnection();&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;            return Convert.ToInt32(identity);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void GetExecuteNonQueryByCommand(string Command)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.CommandText = Command;&lt;br /&gt;                oCommand.CommandTimeout = iTimeOut;&lt;br /&gt;                oCommand.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;                oConnection.Open();&lt;br /&gt;&lt;br /&gt;                oCommand.Connection = oConnection;&lt;br /&gt;                oCommand.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;                CloseConnection();&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                CloseConnection();&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void GetExecuteNonQueryBySQL(string strSQL)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.CommandText = strSQL;&lt;br /&gt;                oCommand.CommandTimeout = iTimeOut;&lt;br /&gt;                oCommand.CommandType = CommandType.Text;&lt;br /&gt;&lt;br /&gt;                oConnection.Open();&lt;br /&gt;&lt;br /&gt;                oCommand.Connection = oConnection;&lt;br /&gt;                oCommand.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;                CloseConnection();&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                CloseConnection();&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public DataSet GetDatasetByCommand(string Command)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.CommandText = Command;&lt;br /&gt;                oCommand.CommandTimeout = iTimeOut;&lt;br /&gt;                oCommand.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;                oConnection.Open();&lt;br /&gt;&lt;br /&gt;                OracleDataAdapter adpt = new OracleDataAdapter(oCommand);&lt;br /&gt;                DataSet ds = new DataSet();&lt;br /&gt;                adpt.Fill(ds);&lt;br /&gt;                return ds;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                CloseConnection();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public DataSet GetDatasetBySQL(string strSQL)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.CommandText = strSQL;&lt;br /&gt;                oCommand.CommandTimeout = iTimeOut;&lt;br /&gt;                oCommand.CommandType = CommandType.Text;&lt;br /&gt;&lt;br /&gt;                oConnection.Open();&lt;br /&gt;&lt;br /&gt;                OracleDataAdapter Adapter  = new OracleDataAdapter(strSQL, oConnection);&lt;br /&gt;                DataSet ds = new DataSet();&lt;br /&gt;                Adapter.Fill(ds);&lt;br /&gt;                return ds;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                CloseConnection();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public OracleDataReader GetReaderBySQL(string strSQL)&lt;br /&gt;        {&lt;br /&gt;            oConnection.Open();&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                OracleCommand myCommand = new OracleCommand(strSQL, oConnection);&lt;br /&gt;                return myCommand.ExecuteReader();&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                CloseConnection();&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public OracleDataReader GetReaderByCmd(string Command)&lt;br /&gt;        {&lt;br /&gt;            OracleDataReader objOracleDataReader = null;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.CommandText = Command;&lt;br /&gt;                oCommand.CommandType = CommandType.StoredProcedure;&lt;br /&gt;                oCommand.CommandTimeout = iTimeOut;&lt;br /&gt;&lt;br /&gt;                oConnection.Open();&lt;br /&gt;                oCommand.Connection = oConnection;&lt;br /&gt;&lt;br /&gt;                objOracleDataReader = oCommand.ExecuteReader() ;&lt;br /&gt;                return objOracleDataReader;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                CloseConnection();&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void AddParameterToSQLCommand(string ParameterName, OracleType ParameterType)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.Parameters.Add(new OracleParameter(ParameterName, ParameterType));&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        public void AddParameterToSQLCommand(string ParameterName, OracleType ParameterType,int ParameterSize)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.Parameters.Add(new OracleParameter(ParameterName, ParameterType, ParameterSize));&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        public void SetSQLCommandParameterValue(string ParameterName, object Value)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                oCommand.Parameters[ParameterName].Value = Value;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                throw ex;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-3104227636478011022?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/3104227636478011022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/oraclehelpercs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/3104227636478011022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/3104227636478011022'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/oraclehelpercs.html' title='OracleHelper.cs'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-4306598742434348855</id><published>2009-05-27T03:19:00.000-07:00</published><updated>2009-05-27T03:22:01.264-07:00</updated><title type='text'>Attributes in C#.Net</title><content type='html'>&lt;strong&gt;Attributes are a new kind of declarative information. We can use attributes to define both design-level information (such as help file, URL for documentation) and run-time information (such as associating XML field with class field). We can also create "self-describing" components using attributes. &lt;/strong&gt;&lt;br /&gt;&lt;em&gt;&lt;br /&gt;"An attribute is a piece of additional declarative information that is specified for a declaration."&lt;/em&gt;  - MSDN&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Attributes&lt;/strong&gt;&lt;br /&gt;C# allows you to add declarative information to a program in the form of an attribute. An attribute defines additional information (metadata) that is associated with a class, structure, method, and so on. For example, you might define an attribute that determines the type of button that a class will display. Attributes are specified between square brackets, preceding the item to which they apply. Thus, an attribute is not a member of a class. Rather, an attribute specifies supplemental information that is attached to an item.&lt;br /&gt;When do we need attributes ?&lt;br /&gt;&lt;br /&gt;The advantage of using attributes resides in the fact that the information that it contains is inserted into the assembly. This information can then be consumed at various times for all sorts of purposes:&lt;br /&gt;1. An attribute can be consumed by the compiler. The System.ObsoleteAttribute attribute that we have just described is a good example of how an attribute is used by the compiler, certain standard attributes which are only destined for the compiler are not stored in the assembly. For example, the SerializationAttribute attribute does not directly mark a type but rather tells the compiler that type can be serialized. Consequently, the compiler sets certain flags on the concerned type which will be consumed by the CLR during execution such attributes are also named pseudo-attributes. &lt;br /&gt;2. An attribute can be consumed by the CLR during execution. For example the .NET Framework offers the System.ThreadStaticAttribute attribute. When a static field is marked with this attribute the CLR makes sure that during the execution, there is only one version of this field per thread. &lt;br /&gt;3. An attribute can be consumed by a debugger during execution. Hence, the System.Diagnostics.DebuggerDisplayAttribute attribute allows personalizing the display of an element of the code(the state of an object for example) during debugging. &lt;br /&gt;4. An attribute can be consumed by a tool, for example, the .NET framework offers the System.Runtime.InteropServices.ComVisibleAttribute attribute. When a class is marked with this attribute, the tlbexp.exe tool generates a file which will allow this class to be consumed as if it was a COM object. &lt;br /&gt;5. An attribute can be consumed by your own code during execution by using the reflection mechanism to access the information. For example, it can be interesting to use such attributes to validate the value of fields in your classes. Such a field must be within a certain range. Another reference field must not be null. A string field can be atmost 100 character. Because of the reflection mechanism, it is easy to write code to  validate the state of any marked fields. A little later, we will show you such an example where you can consume attributes by your own code. &lt;br /&gt;6. An attribute can be consumed by a user which analyses an assembly with a tool such as ildasm.exe or Reflector. Hence you could imagine an attribute which would associate a character string to an element of your code. This string being contained in the assembly, it is then possible to consult these comments without needing to access source code.&lt;br /&gt;Things to know about attributes&lt;br /&gt;1. An attribute must be defined by a class which derives from System.Attribute. &lt;br /&gt;2. An Instance of the attribute class is only instantiated when the reflection mechanism accesses one of its representatives, Depending on its use, an attribute class in not necessarily instantiated(as with the System.ObsoleteAttribute class which does not need to be used by the reflection mechanism). &lt;br /&gt;3. The .NET framework puts several attributes to your disposition. Certain attributes are destined to be used by the CLR. Other are consumed by the compiler or tools supplied by Microsoft. &lt;br /&gt;4. You have the possibility of creating your own attribute classes, They will then necessarily be consumed by your program as you cannot tinker the compiler or the CLR. &lt;br /&gt;5. By convention, the name of an attribute class is suffixed by Attribute. However, an attribute named XXXAttribute can be used in c# both using the XXXAttribute expression but also with the XXX expression when it marks an element of the code.&lt;br /&gt;&lt;em&gt;Reference: &lt;br /&gt;Practical .NET2 and C#2 By Patrick Smacchia&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Attribute Basics&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;An attribute is supported by a class that inherits System.Attribute. Thus, all attribute classes must be subclasses of Attribute. Although Attribute defines substantial functionality, this functionality is not always needed when working with attributes. By convention, attribute classes often use the suffix Attribute. For example, ErrorAttribute would be a name for an attribute class that described an error.&lt;br /&gt;When an attribute class is declared, it is preceded by an attribute called AttributeUsage. This built-in attribute specifies the types of items to which the attribute can be applied. Thus, the usage of an attribute can be restricted to methods, for example. &lt;br /&gt;Creating an Attribute&lt;br /&gt;In an attribute class, you will define the members that support the attribute. Often attribute classes are quite simple, containing just a small number of fields or properties. For example, an attribute might define a Note that describes the item to which the attribute is being attached. Such an attribute might look like this: &lt;br /&gt;[AttributeUsage(AttributeTargets.All)]&lt;br /&gt;public class NoteAttribute : Attribute {&lt;br /&gt;  string strNote; &lt;br /&gt;&lt;br /&gt;  public NoteAttribute(string comment) {&lt;br /&gt;    strNote = comment;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public string Note {&lt;br /&gt;    get {&lt;br /&gt;      return strNote;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;Let’s look at this class, line by line.&lt;br /&gt;The name of this attribute is NoteAttribute. Its declaration is preceded by the AttributeUsage attribute, which specifies that NoteAttribute can be applied to all types of items. Using AttributeUsage, it is possible to narrow the list of items to which an attribute can be attached, and we will examine its capabilities later in this chapter.&lt;br /&gt;Next, NoteAttribute is declared and it inherits Attribute. Inside NoteAttribute there is one private field, strNote, which supports one public, read-only property: Note. This property holds the description that will be associated with the attribute. There is one public constructor that takes a string argument and assigns it to Note.&lt;br /&gt;At this point, no other steps are needed, and NoteAttribute is ready for use.&lt;br /&gt;Attaching an Attribute&lt;br /&gt;Once you have defined an attribute class, you can attach the attribute to an item. An attribute precedes the item to which it is attached and is specified by enclosing its constructor inside square brackets. For example, here is how NoteAttribute can be associated with a class: &lt;br /&gt;[NoteAttribute("This class uses an attribute.")]&lt;br /&gt;class UseAttrib {&lt;br /&gt;  // ...&lt;br /&gt;}&lt;br /&gt;This constructs a NoteAttribute that contains the comment “This class uses an attribute.” This attribute is then associated with UseAttrib.&lt;br /&gt;When attaching an attribute, it is not actually necessary to specify the “Attribute” suffix. For example, the preceding class could be declared this way: &lt;br /&gt;[Note("This class uses an attribute.")]&lt;br /&gt;class UseAttrib {&lt;br /&gt;  // ...&lt;br /&gt;}&lt;br /&gt;Here, only the name Note is used. Although the short form is correct, it is usually refer to use the full name when attaching attributes, because it avoids possible confusion and ambiguity.&lt;br /&gt;Obtaining an Object’s Attributes&lt;br /&gt;Once an attribute has been attached to an item, other parts of the program can retrieve the attribute. To retrieve an attribute, you will usually use one of two methods. The first is GetCustomAttributes( ), which is defined by MemberInfo and inherited by Type. It retrieves a list of all attributes attached to an item. Here is one of its forms: &lt;br /&gt;object[ ] GetCustomAttributes(bool searchBases)&lt;br /&gt;If searchBases is true, then the attributes of all base classes through the inheritance chain will be included. Otherwise, only those classes defined by the specified type will be found.&lt;br /&gt;The second method is GetCustomAttribute( ), which is defined by Attribute. One of its forms is shown here: &lt;br /&gt;static Attribute GetCustomAttribute(MemberInfo mi, Type attribtype)&lt;br /&gt;Here, mi is a MemberInfo object that describes the item for which the attributes are being obtained. The attribute desired is specified by attribtype. You will use this method when you know the name of the attribute you want to obtain, which is often the case. For example, assuming that the UseAttrib class has the NoteAttribute, to obtain a reference to the NoteAttribute, you can use a sequence like this: &lt;br /&gt;// Get a MemberInfo instance associated with a&lt;br /&gt;// class that has the NoteAttribute.&lt;br /&gt;Type t = typeof(UseAttrib);&lt;br /&gt;&lt;br /&gt;// Retrieve the NoteAttribute.&lt;br /&gt;Type tRemAtt = typeof(NoteAttribute);&lt;br /&gt;NoteAttribute ra = (NoteAttribute)&lt;br /&gt;      Attribute.GetCustomAttribute(t, tRemAtt);&lt;br /&gt;This sequence works because MemberInfo is a base class of Type. Thus, t is a MemberInfo instance.&lt;br /&gt;Once you have a reference to an attribute, you can access its members. Thus, information associated with an attribute is available to a program that uses an element to which an attribute is attached. For example, the following statement displays the Note field: &lt;br /&gt;Console.WriteLine(ra.Note);&lt;br /&gt;The following program puts together all of the pieces and demonstrates the use of NoteAttribute:&lt;br /&gt;// A simple attribute example.&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Reflection;&lt;br /&gt;&lt;br /&gt;[AttributeUsage(AttributeTargets.All)]&lt;br /&gt;public class NoteAttribute : Attribute {&lt;br /&gt;  string strNote;  &lt;br /&gt;public NoteAttribute(string comment) {&lt;br /&gt;    strNote = comment;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public string Note {&lt;br /&gt;    get {&lt;br /&gt;      return strNote;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;[NoteAttribute("This class uses an attribute.")]&lt;br /&gt;class UseAttrib {&lt;br /&gt;  // ...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class AttribDemo {&lt;br /&gt;  public static void Main() {&lt;br /&gt;    Type t = typeof(UseAttrib);&lt;br /&gt;&lt;br /&gt;    Console.Write("Attributes in " + t.Name + ": ");&lt;br /&gt;&lt;br /&gt;    object[] attribs = t.GetCustomAttributes(false);&lt;br /&gt;    foreach(object o in attribs) {&lt;br /&gt;      Console.WriteLine(o);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    Console.Write("Note: ");&lt;br /&gt;&lt;br /&gt;    // Retrieve the NoteAttribute.&lt;br /&gt;    Type tRemAtt = typeof(NoteAttribute);&lt;br /&gt;    NoteAttribute ra = (NoteAttribute)&lt;br /&gt;          Attribute.GetCustomAttribute(t, tRemAtt);&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(ra.Note);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;The output from the program is shown here: &lt;br /&gt;Attributes in UseAttrib: NoteAttribute&lt;br /&gt;Note: This class uses an attribute.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-4306598742434348855?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/4306598742434348855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/attributes-in-cnet.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/4306598742434348855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/4306598742434348855'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/attributes-in-cnet.html' title='Attributes in C#.Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-5989443525624006687</id><published>2009-05-23T05:24:00.000-07:00</published><updated>2009-05-23T05:26:20.110-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>SortedLIst in .Net</title><content type='html'>&lt;em&gt;Published article on eggheadcafe.com&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;using System.Collections;&lt;br /&gt;&lt;br /&gt;namespace ConsoleApps&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;public class ClsSortedList&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;// create a SortedList object&lt;br /&gt;&lt;br /&gt;SortedList mySortedList = new SortedList();&lt;br /&gt;&lt;br /&gt;// add elements containing US state abbreviations and state&lt;br /&gt;&lt;br /&gt;// names to mySortedList using the Add() method&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public void MainFunction()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;mySortedList.Add("NY", "New York");&lt;br /&gt;&lt;br /&gt;mySortedList.Add("FL", "Florida");&lt;br /&gt;&lt;br /&gt;mySortedList.Add("AL", "Alabama");&lt;br /&gt;&lt;br /&gt;mySortedList.Add("WY", "Wyoming");&lt;br /&gt;&lt;br /&gt;mySortedList.Add("CA", "California");&lt;br /&gt;&lt;br /&gt;// display the keys for mySortedList using the Keys property&lt;br /&gt;&lt;br /&gt;foreach (string myKey in mySortedList.Keys)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Console.WriteLine("myKey = " + myKey);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// display the values for mySortedList using the Values property&lt;br /&gt;&lt;br /&gt;foreach (string myValue in mySortedList.Values)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Console.WriteLine("myValue = " + myValue);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// use the ContainsKey() method to check if mySortedList&lt;br /&gt;&lt;br /&gt;// contains the key "FL"&lt;br /&gt;&lt;br /&gt;if (mySortedList.ContainsKey("FL"))&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Console.WriteLine("mySortedList contains the key FL");&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// use the ContainsValue() method to check if mySortedList&lt;br /&gt;&lt;br /&gt;// contains the value "Florida"&lt;br /&gt;&lt;br /&gt;if (mySortedList.ContainsValue("Florida"))&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Console.WriteLine("mySortedList contains the value Florida");&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// use the Remove() method to remove FL from mySortedList&lt;br /&gt;&lt;br /&gt;Console.WriteLine("Removing FL from mySortedList");&lt;br /&gt;&lt;br /&gt;mySortedList.Remove("FL");&lt;br /&gt;&lt;br /&gt;// get the key at index 3 using the GetKey() method&lt;br /&gt;&lt;br /&gt;string keyAtIndex3 = (string)mySortedList.GetKey(3);&lt;br /&gt;&lt;br /&gt;Console.WriteLine("The key at index 3 is " + keyAtIndex3);&lt;br /&gt;&lt;br /&gt;// get the index of the element with the key "NY"&lt;br /&gt;&lt;br /&gt;// using the IndexOfKey() method&lt;br /&gt;&lt;br /&gt;int myIndex = mySortedList.IndexOfKey("NY");&lt;br /&gt;&lt;br /&gt;Console.WriteLine("The index of NY is " + myIndex);&lt;br /&gt;&lt;br /&gt;// get the index of the element with the value "New York"&lt;br /&gt;&lt;br /&gt;// using the IndexOfValue() method&lt;br /&gt;&lt;br /&gt;myIndex = mySortedList.IndexOfValue("New York");&lt;br /&gt;&lt;br /&gt;Console.WriteLine("The index of New York is " + myIndex);&lt;br /&gt;&lt;br /&gt;// replace the value of the element at myIndex with "New York State"&lt;br /&gt;&lt;br /&gt;// using the SetByIndex() method&lt;br /&gt;&lt;br /&gt;Console.WriteLine("Replacing the value New York with New York State");&lt;br /&gt;&lt;br /&gt;mySortedList.SetByIndex(myIndex, "New York State");&lt;br /&gt;&lt;br /&gt;// get the key list using the GetKeyList() method&lt;br /&gt;&lt;br /&gt;Console.WriteLine("Getting the key list");&lt;br /&gt;&lt;br /&gt;IList myKeyList = mySortedList.GetKeyList();&lt;br /&gt;&lt;br /&gt;foreach (string myKey in myKeyList)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Console.WriteLine("myKey = " + myKey);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// get the value list using the GetValueList() method&lt;br /&gt;&lt;br /&gt;Console.WriteLine("Getting the value list");&lt;br /&gt;&lt;br /&gt;IList myValueList = mySortedList.GetValueList();&lt;br /&gt;&lt;br /&gt;foreach (string myValue in myValueList)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Console.WriteLine("myValue = " + myValue);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt; Visit: http://www.eggheadcafe.com/tutorials/aspnet/c5681544-1f64-4977-8367-4803511f6c84/sortedlist-in-cnet.aspx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-5989443525624006687?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/5989443525624006687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/sortedlist-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/5989443525624006687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/5989443525624006687'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/sortedlist-in-net.html' title='SortedLIst in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-7097726094011310962</id><published>2009-05-22T01:20:00.000-07:00</published><updated>2009-05-22T01:21:29.159-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>How to Read text file as database</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data.OleDb;&lt;br /&gt;using System.Data;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;namespace PubishApps&lt;br /&gt;{&lt;br /&gt;    public class ReadTextFileAsDB&lt;br /&gt;    {&lt;br /&gt;/************************************************&lt;br /&gt;* Topic : How to Read text file as database&lt;br /&gt;* Use : Client code could implement DB-Query on text file.&lt;br /&gt;* Author : kalit sikka&lt;br /&gt;* For : http://eggheadcafe.com&lt;br /&gt;* **********************************************/&lt;br /&gt;&lt;br /&gt;        OleDbConnection oConnection = new OleDbConnection();&lt;br /&gt;&lt;br /&gt;        private bool OpenConnection(string InputTextFileName)&lt;br /&gt;        {&lt;br /&gt;            if(!string.IsNullOrEmpty(InputTextFileName))&lt;br /&gt;            {&lt;br /&gt;                oConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"+InputTextFileName+"'; Extended Properties=text;HDR=yes;FMT=Delimited";&lt;br /&gt;                oConnection.Open();&lt;br /&gt;&lt;br /&gt;                if(oConnection.State == System.Data.ConnectionState.Open)&lt;br /&gt;                    return true;&lt;br /&gt;                else&lt;br /&gt;                    return false;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return false;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void BindingDataToGridView(string InputTextFileName, string Query, DataSet ds)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                OpenConnection(InputTextFileName);&lt;br /&gt;&lt;br /&gt;                // Create the data adapter to retrieve all rows from text file.&lt;br /&gt;                OleDbDataAdapter da =&lt;br /&gt;                    new OleDbDataAdapter(Query, oConnection);&lt;br /&gt;                 &lt;br /&gt;                // Create and fill the table.&lt;br /&gt;                DataSet dt = new DataSet("MyData");&lt;br /&gt;                da.Fill(dt);&lt;br /&gt;                ds = dt.Copy();&lt;br /&gt;&lt;br /&gt;                // Bind the default view of the table to the grid.&lt;br /&gt;             //   DBview.DataSource = dt.DefaultView;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            }catch(Exception ex)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("Error Occured: "+ ex.Message);&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                if(oConnection.State == System.Data.ConnectionState.Open)&lt;br /&gt;                {&lt;br /&gt;                    oConnection.Close();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Visit: http://www.eggheadcafe.com/tutorials/aspnet/8ce269f0-9654-4e61-937e-8f591434e2bd/how-to-read-text-file-as.aspx&lt;br /&gt;&lt;br /&gt;Collection of Code Snippet: http://kalit-codesnippetsofnettechnology.blogspot.com/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-7097726094011310962?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/7097726094011310962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-to-read-text-file-as-database_22.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7097726094011310962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7097726094011310962'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-to-read-text-file-as-database_22.html' title='How to Read text file as database'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-7835845862217877654</id><published>2009-05-22T01:18:00.000-07:00</published><updated>2009-05-22T01:19:15.921-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>To Extract Unique/All Sub-Strings from the string</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Text.RegularExpressions;&lt;br /&gt;using System.Collections;&lt;br /&gt;&lt;br /&gt;namespace PubishApps&lt;br /&gt;{&lt;br /&gt;    class FindSubStringRegex&lt;br /&gt;    {&lt;br /&gt;        &lt;br /&gt; /************************************************&lt;br /&gt;* Topic : To Extract Unique/All Sub-Strings from the string&lt;br /&gt;* Reference Required: System.Text.RegularExpressions.&lt;br /&gt;* Author : kalit sikka&lt;br /&gt;* For : http://eggheadcafe.com&lt;br /&gt;* **********************************************/&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// To Extract Unique/All Sub-Strings from the string&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="source"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;param name="matchPattern"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;param name="findAllUnique"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;         &lt;br /&gt;        public  Match[] FindSubstrings(string source, string matchPattern,&lt;br /&gt;                                     bool findAllUnique)&lt;br /&gt;                { &lt;br /&gt;                    SortedList uniqueMatches = new SortedList( );&lt;br /&gt;                    Match[] retArray = null;&lt;br /&gt;&lt;br /&gt;                    Regex RE = new Regex(matchPattern, RegexOptions.Multiline);&lt;br /&gt;                    MatchCollection theMatches = RE.Matches(source);&lt;br /&gt;&lt;br /&gt;                    if (findAllUnique)&lt;br /&gt;                    {&lt;br /&gt;                        for (int counter = 0; counter &lt; theMatches.Count; counter++)&lt;br /&gt;                        {&lt;br /&gt;                            if (!uniqueMatches.ContainsKey(theMatches[counter].Value))&lt;br /&gt;                            {&lt;br /&gt;&lt;br /&gt;                                uniqueMatches.Add(theMatches[counter].Value,&lt;br /&gt;                                                  theMatches[counter]);&lt;br /&gt;                            }&lt;br /&gt;                        }&lt;br /&gt;                        retArray = new Match[uniqueMatches.Count];&lt;br /&gt;                        uniqueMatches.Values.CopyTo(retArray, 0);&lt;br /&gt;                    }&lt;br /&gt;                    else&lt;br /&gt;                    {&lt;br /&gt;                        retArray = new Match[theMatches.Count];&lt;br /&gt;                        theMatches.CopyTo(retArray, 0);&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    return (retArray);&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            &lt;br /&gt;           // Sample Text&lt;br /&gt;            string Text=@"Search Tutorials &amp; Message Boards &lt;br /&gt;            Silverlight    WPF    WCF    WWF    LINQ     &lt;br /&gt;            JavaScript    AJAX    ASP.NET    XAML     &lt;br /&gt;            C#    VB.NET    VB 6.0    GDI+    IIS    XML     &lt;br /&gt;            .NET Generics    Anonymous Methods    Delegate     &lt;br /&gt;            Visual Studio .NET    Expression Blend    Virus     &lt;br /&gt;            Windows Vista    Windows XP    Windows Update     &lt;br /&gt;            Windows 2003 Server    Windows 2008 Server     &lt;br /&gt;            SQL Server    Microsoft Excel    Microsoft Word     &lt;br /&gt;            SharePoint    BizTalk    Virtual Earth     &lt;br /&gt;            .NET Compact Framework    Web Service     &lt;br /&gt;             &lt;br /&gt;            Recent Articles &amp; Code Samples &lt;br /&gt;            Scheduling SSIS packages as job &lt;br /&gt;             &lt;br /&gt;            Appending data to an existing file in VB.NET &lt;br /&gt;             &lt;br /&gt;            Writing to a file using FileStream in VB.NET &lt;br /&gt;             &lt;br /&gt;            Copy, delete and move files in VB.NET &lt;br /&gt;             &lt;br /&gt;            Error handling in SSIS &lt;br /&gt;             &lt;br /&gt;            Error connecting to FTP server using SSIS FTP task &lt;br /&gt;             &lt;br /&gt;            Embedding an image in a mail &lt;br /&gt;             &lt;br /&gt;            Sending email in SSIS using script task &lt;br /&gt;             &lt;br /&gt;            ASP.NET Cache dependency example &lt;br /&gt;             &lt;br /&gt;            How Export Data from DataGrid to Excel &lt;br /&gt;             &lt;br /&gt;            Data Compression in SQL SERVER 2008"; &lt;br /&gt; &lt;br /&gt;            string matchPattern = "ASP.NET";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                FindSubStringRegex oFind = new FindSubStringRegex();&lt;br /&gt;                Console.WriteLine("UNIQUE MATCHES");&lt;br /&gt;                Match[] x1 = oFind.FindSubstrings(Text, matchPattern, true);&lt;br /&gt;                foreach(Match m in x1)&lt;br /&gt;                {&lt;br /&gt;                    Console.WriteLine(m.Value);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                Console.WriteLine( );&lt;br /&gt;                Console.WriteLine("ALL MATCHES");&lt;br /&gt;                Match[] x2 = oFind.FindSubstrings(Text, matchPattern, false);&lt;br /&gt;                foreach(Match m in x2)&lt;br /&gt;                {&lt;br /&gt;                    Console.WriteLine(m.Value);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Visit: http://www.eggheadcafe.com/tutorials/aspnet/b6277277-89d0-4b4d-9bac-2cd77e929f19/to-extract-uniqueall-sub.aspx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-7835845862217877654?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/7835845862217877654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/to-extract-uniqueall-sub-strings-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7835845862217877654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7835845862217877654'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/to-extract-uniqueall-sub-strings-from.html' title='To Extract Unique/All Sub-Strings from the string'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-8735731423418104927</id><published>2009-05-22T01:09:00.000-07:00</published><updated>2009-05-22T01:10:48.894-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>How to get all URLs of the page</title><content type='html'>Topic : How to get all URLs of the page&lt;br /&gt;namespace PubishApps&lt;br /&gt;{&lt;br /&gt;    class FetchURLsFromSite&lt;br /&gt;    {&lt;br /&gt;    &lt;br /&gt;/************************************************&lt;br /&gt;* Topic : How to fetch all URLs of the site.&lt;br /&gt;* Author : kalit sikka&lt;br /&gt;* For : http://eggheadcafe.com&lt;br /&gt;* **********************************************/&lt;br /&gt;  &lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// To fetch all URLs name from the site&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="webPage"&gt;&lt;/param&gt;&lt;br /&gt;          public void FetchUrls( string webPage ) &lt;br /&gt;          { &lt;br /&gt;           GetAllUrls(GetContent(webPage)); &lt;br /&gt;          } &lt;br /&gt;&lt;br /&gt;           &lt;br /&gt;         /// &lt;summary&gt;&lt;br /&gt;         /// Get the content of the web page&lt;br /&gt;         /// &lt;/summary&gt;&lt;br /&gt;         /// &lt;param name="webPage"&gt;&lt;/param&gt;&lt;br /&gt;         /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;          private string GetContent(string webPage) &lt;br /&gt;          { &lt;br /&gt;           HttpWebResponse response = null;//used to get response &lt;br /&gt;           StreamReader respStream = null;//used to read response into string &lt;br /&gt;           try &lt;br /&gt;           { &lt;br /&gt;            //create a request object using the url passed in &lt;br /&gt;            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(webPage); &lt;br /&gt;            request.Timeout = 10000; &lt;br /&gt;&lt;br /&gt;            //go get a response from the page &lt;br /&gt;            response = (HttpWebResponse)request.GetResponse(); &lt;br /&gt;            &lt;br /&gt;            //create a streamreader object from the response &lt;br /&gt;            respStream = new StreamReader(response.GetResponseStream()); &lt;br /&gt;&lt;br /&gt;            //get the contents of the page as a string and return it &lt;br /&gt;            return respStream.ReadToEnd();   &lt;br /&gt;           } &lt;br /&gt;           catch (Exception ex) &lt;br /&gt;           { &lt;br /&gt;            throw ex; &lt;br /&gt;           } &lt;br /&gt;           finally &lt;br /&gt;           { &lt;br /&gt;            //close it down, we're going home! &lt;br /&gt;            response.Close(); &lt;br /&gt;            respStream.Close(); &lt;br /&gt;           } &lt;br /&gt;          } &lt;br /&gt;          &lt;br /&gt;          /// &lt;summary&gt;&lt;br /&gt;          /// Use regular expression to filter required URLs&lt;br /&gt;          /// &lt;/summary&gt;&lt;br /&gt;          /// &lt;param name="content"&gt;&lt;/param&gt;&lt;br /&gt;         &lt;br /&gt;          private void GetAllUrls(string content) &lt;br /&gt;          { &lt;br /&gt;           &lt;br /&gt;          // Address of local LogFile&lt;br /&gt;          string LocalFile = @"C:\Documents and Settings\kalit.20413\My Documents\LogFile.txt";&lt;br /&gt; &lt;br /&gt;          //regular expression &lt;br /&gt;           string pattern = @"(?:href\s*=)(?:[\s""']*)(?!#|mailto|location.|javascript|.*css|.*this\.)(?&lt;br /&gt;        .*?)(?:[\s&gt;""'])"; &lt;br /&gt;           &lt;br /&gt;           //Set up regex object &lt;br /&gt;           Regex RegExpr = new Regex(pattern, RegexOptions.IgnoreCase); &lt;br /&gt;&lt;br /&gt;           //get the first match &lt;br /&gt;           Match match = RegExpr.Match(content); &lt;br /&gt;&lt;br /&gt;           //loop through matches &lt;br /&gt;           while (match.Success) &lt;br /&gt;           { &lt;br /&gt;&lt;br /&gt;            //output the match info &lt;br /&gt;            Console.WriteLine("href match: " + match.Groups[0].Value); &lt;br /&gt;            WriteToLog(LocalFile, "href match: " + match.Groups[0].Value + "\r\n"); &lt;br /&gt;&lt;br /&gt;            Console.WriteLine("Url match: " + match.Groups[1].Value); &lt;br /&gt;                &lt;br /&gt;            //get next match &lt;br /&gt;            match = match.NextMatch(); &lt;br /&gt;           } &lt;br /&gt;          } &lt;br /&gt;&lt;br /&gt;          /// &lt;summary&gt;&lt;br /&gt;          /// Write log at local machine&lt;br /&gt;          /// &lt;/summary&gt;&lt;br /&gt;          /// &lt;param name="file"&gt;&lt;/param&gt;&lt;br /&gt;          /// &lt;param name="message"&gt;&lt;/param&gt;&lt;br /&gt;          private void WriteToLog(string file, string message) &lt;br /&gt;          { &lt;br /&gt;           using (StreamWriter w = File.AppendText(file)) &lt;br /&gt;           { &lt;br /&gt;            w.WriteLine(DateTime.Now.ToString() + ": " + message); &lt;br /&gt;            w.Close(); &lt;br /&gt;           } &lt;br /&gt;          } &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Visit: http://www.eggheadcafe.com/tutorials/aspnet/23ce657b-87a9-45b3-856d-1c891803fcbd/how-to-get-all-urls-of-th.aspx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-8735731423418104927?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/8735731423418104927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-to-get-all-urls-of-page.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8735731423418104927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8735731423418104927'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-to-get-all-urls-of-page.html' title='How to get all URLs of the page'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-8313803785487250674</id><published>2009-05-22T01:06:00.000-07:00</published><updated>2009-05-22T01:08:34.122-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Message Queuing'/><title type='text'>Message Queuing in .Net</title><content type='html'>Message Queuing in C#.net&lt;br /&gt;Creating a Message Queue&lt;br /&gt;Message queues can be created programmatically with the Create() method of the MessageQueue class.&lt;br /&gt;With the Create() method, the path of the new queue must be passed. The path consists of the host name where the queue is located and the name of the queue. In the example, the queue MyNewPublicQueue is created on the local host. To create a private queue the path name must include Private$; for example, c:\kalit\Private$\MyNewPrivateQueue.&lt;br /&gt;After the Create() method is invoked, properties of queue can be changed. For example, using the Label property, the label of the queue is set to Demo Queue. The sample program writes the path of the queue and the format name to the console. The format name is automatically created with a UUID that can be used to access the queue without the name of the server:&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Messaging;&lt;br /&gt;&lt;br /&gt;namespace MessageQueuingInDot&lt;br /&gt;{&lt;br /&gt;   class Program&lt;br /&gt;   {&lt;br /&gt;      static void Main()&lt;br /&gt;      {&lt;br /&gt;         using (MessageQueue queue = MessageQueue.Create(@".\MyNewPublicQueue"))&lt;br /&gt;         {&lt;br /&gt;            queue.Label = "Demo Queue";&lt;br /&gt;            Console.WriteLine("Queue created:");&lt;br /&gt;            Console.WriteLine("Path: {0}", queue.Path);&lt;br /&gt;            Console.WriteLine("FormatName: {0}", queue.FormatName);&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;Finding a Queue&lt;br /&gt;The path name and the format name can be used to identify queues. To find queues, you must differentiate between public and private queues. Public queues are published in the Active Directory. For these queues, it is not necessary to know the system where they are located. Private queues can be found only if the name of the system where the queue is located is known.&lt;br /&gt;You can find public queues in the Active Directory domain by searching for the queue’s label, category, or format name. You can also get all queues on a machine. The class MessageQueue has static methods to search for queues: GetPublicQueuesByLabel(), GetPublicQueuesByCategory(), and GetPublicQueuesByMachine(). The method GetPublicQueues() returns an array of all public queues in the domain:&lt;br /&gt;using System;&lt;br /&gt;using System.Messaging;&lt;br /&gt;&lt;br /&gt;namespace MessageQueuingInDot&lt;br /&gt;{&lt;br /&gt;   class Program&lt;br /&gt;   {&lt;br /&gt;      static void Main()&lt;br /&gt;      {&lt;br /&gt;         foreach (MessageQueue queue in MessageQueue.GetPublicQueues())&lt;br /&gt;         {&lt;br /&gt;            Console.WriteLine(queue.Path);&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;The method GetPublicQueues() is overloaded. One version allows passing an instance of the MessageQueueCriteria class. With this class, you can search for queues created or modified before or after a certain time, and you can also look for a category, label, or machine name.&lt;br /&gt;Private queues can be searched with the static method GetPrivateQueuesByMachine(). This method returns all private queues from a specific system.&lt;br /&gt;Opening Known Queues&lt;br /&gt;If the name of the queue is known, it is not necessary to search for it. Queues can be opened by using the path or format name. They both can be set in the constructor of the MessageQueue class.&lt;br /&gt;Path Name&lt;br /&gt;The path specifies the machine name and the queue name to open the queue. This code example opens the queue MyPublicQueue on the local host. To be sure that the queue exists, you use the static method MessageQueue.Exists():&lt;br /&gt;using System;&lt;br /&gt;using System.Messaging;&lt;br /&gt;&lt;br /&gt;namespace MessageQueuingInDot&lt;br /&gt;{&lt;br /&gt;   class Program&lt;br /&gt;   {&lt;br /&gt;      static void Main()&lt;br /&gt;      {&lt;br /&gt;         if (MessageQueue.Exists(@".\MyPublicQueue"))&lt;br /&gt;         {&lt;br /&gt;            MessageQueue queue = new MessageQueue(@".\MyPublicQueue");&lt;br /&gt;            //...&lt;br /&gt;         }&lt;br /&gt;         else&lt;br /&gt;         {&lt;br /&gt;            Console.WriteLine("Queue .\MyPublicQueue not existing");&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;Depending on the queue type, different identifiers are required when queues are opened. The following table shows the syntax of the queue name for specific types.&lt;br /&gt; Open table as spreadsheet Queue Type  Syntax &lt;br /&gt;Public queue  MachineName\QueueName &lt;br /&gt;Private queue  MachineName\Private$\QueueName &lt;br /&gt;Journal queue  MachineName\QueueName\Journal$ &lt;br /&gt;Machine journal queue  MachineName\Journal$ &lt;br /&gt;Machine dead-letter queue  MachineName\DeadLetter$ &lt;br /&gt;Machine transactional dead-letter queue  MachineName\XactDeadLetter$ &lt;br /&gt;When you use the path name to open public queues, it is necessary to pass the machine name. If the machine name is not known, the format name can be used instead. The path name for private queues can only be used on the local system. The format name must be used to access private queues remotely.&lt;br /&gt;Format Name&lt;br /&gt;Instead of the path name, you can use the format name to open a queue. The format name is used for searching the queue in the Active Directory to get the host where the queue is located. In a disconnected environment where the queue cannot be reached at the time the message is sent, it is necessary to use the format name:&lt;br /&gt;&lt;br /&gt;MessageQueue queue = new MessageQueue(&lt;br /&gt;      @"FormatName:PUBLIC=");&lt;br /&gt;The format name has some different uses. It can be used to open private queues and to specify a protocol that should be used:&lt;br /&gt;•         To access a private queue, the string that has to be passed to the constructor is FormatName:PRIVATE=MachineGUID\QueueNumber. The queue number for private queues is generated when the queue is created. You can see the queue numbers in the &lt;windows&gt;\System32\msmq\storage\lqs directory.&lt;br /&gt;•         With FormatName:DIRECT=Protocol:MachineAddress\QueueName you can specify the protocol that should be used to send the message. The HTTP protocol is supported with Message Queuing 3.0.&lt;br /&gt;•         FormatName:DIRECT=OS:MachineName\QueueName is another way to specify a queue using the format name. This way you don’t have to specify the protocol but still can use the machine name with the format name.&lt;br /&gt;Sending a Message&lt;br /&gt;You can use the Send method of the MessageQueue class to send a message to the queue. The object passed as an argument of the Send() method is serialized to the associated queue. The Send() method is overloaded so that a label and a MessageQueueTransaction object can be passed. Transactional behavior of Message Queuing is discussed later.&lt;br /&gt;The code example first checks if the queue exists. If it doesn’t exist, a queue is created. Then the queue is opened and the message Sample Message is sent to the queue using the Send() method.&lt;br /&gt;The path name specifies “.” for the server name, which is the local system. Path names to private queues only work locally.&lt;br /&gt;using System;&lt;br /&gt;using System.Messaging;&lt;br /&gt;&lt;br /&gt;namespace MessageQueuingInDot&lt;br /&gt;{&lt;br /&gt;   class Program&lt;br /&gt;   {&lt;br /&gt;      static void Main()&lt;br /&gt;      {&lt;br /&gt;         try&lt;br /&gt;         {&lt;br /&gt;            if (!MessageQueue.Exists(@".\Private$\MyPrivateQueue"))&lt;br /&gt;            {&lt;br /&gt;               MessageQueue.Create(@".\Private$\MyPrivateQueue");&lt;br /&gt;            }&lt;br /&gt;            MessageQueue queue = new MessageQueue(@".\Private$\MyPrivateQueue");&lt;br /&gt;            queue.Send("Sample Message", "Label");&lt;br /&gt;         }&lt;br /&gt;         catch (MessageQueueException ex)&lt;br /&gt;         {&lt;br /&gt;            Console.WriteLine(ex.Message);&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;Following shows the Computer Management admin tool where you can see the message that arrived in the queue.&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;By opening the message and selecting the Body tab (see below) of the dialog, you can see that the message was formatted using XML. How the message is formatted is the function of the formatter that’s associated with the message queue.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Message Formatter&lt;br /&gt;The format in which messages are transferred to the queue depends on the formatter. The MessageQueue class has a Formatter property through which a formatter can be assigned. The default formatter, XmlMessageFormatter, will format the message in XML syntax as shown in the previous example.&lt;br /&gt;A message formatter implements the interface IMessageFormatter. Three message formatters are available with the namespace System.Messaging:&lt;br /&gt;•         The XmlMessageFormatter is the default formatter. It serializes objects using XML. &lt;br /&gt;•         With the BinaryMessageFormatter, messages are serialized in a binary format. These messages are shorter than the messages formatted using XML.&lt;br /&gt;•         The ActiveXMessageFormatter is a binary formatter, so that messages can be read or written with COM Objects. Using this formatter, it is possible to write a message to the queue with a .NET class and to read the message from the queue with a COM object or vice versa.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sending Complex Messages&lt;br /&gt;Instead of passing strings, it is possible to pass objects to the Send() method of the MessageQueue class. The type of the class must fulfill some specific requirements, but they depend on the formatter.&lt;br /&gt;For the binary formatter the class must be serializable with the [Serializable] attribute. With the .NET runtime serialization all fields are serialized (this includes private fields). Custom serialization can be defined by implementing the interface ISerializable. &lt;br /&gt;XML serialization takes place with the XML formatter. With XML serialization all public fields and properties are serialized. The XML serialization can be influenced by using attributes from the System.Xml.Serialization namespace. &lt;br /&gt;Receiving Messages&lt;br /&gt;To read messages, again the MessageQueue class can be used. With the Receive() method a single message is read and removed from the queue. If messages are sent with different priorities, the message with the highest priority is read. Reading messages with the same priority may mean that the first message sent is not the first message read because the order of messages across the network is not guaranteed. For a guaranteed order, transactional message queues can be used.&lt;br /&gt;In the following example, a message is read from the private queue MyPrivateQueue. Previously a simple string was passed to the message. When you read a message using the XmlMessageFormatter, you have to pass the types of the objects that are read to the constructor of the formatter. In the example, the type System.String is passed to the argument array of the XmlMessageFormatter constructor. This constructor allows either a String array that contains the types as strings to be passed or a Type array.&lt;br /&gt;The message is read with the Receive() method and then the message body is written to the console:&lt;br /&gt;using System;&lt;br /&gt;using System.Messaging;&lt;br /&gt;&lt;br /&gt;namespace MessageQueuingInDot&lt;br /&gt;{&lt;br /&gt;   class Program&lt;br /&gt;   {&lt;br /&gt;      static void Main(string[] args)&lt;br /&gt;      {&lt;br /&gt;         MessageQueue queue = new MessageQueue(@".\Private$\MyPrivateQueue");&lt;br /&gt;         queue.Formatter = new XmlMessageFormatter(&lt;br /&gt;               new string[] {"System.String"});&lt;br /&gt;&lt;br /&gt;         Message message = queue.Receive();&lt;br /&gt;         Console.WriteLine(message.Body);&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;The Receive() message behaves synchronously and waits until a message is in the queue if there is none.&lt;br /&gt;Enumerating Messages&lt;br /&gt;Instead of reading message by message with the Receive() method, an enumerator can be used to walk through all messages. The MessageQueue class implements the interface IEnumerable and thus can be used with a foreach statement. Here, the messages are not removed from the queue, but you get just a peek at the messages to get their content:&lt;br /&gt;&lt;br /&gt;MessageQueue queue = new MessageQueue(@".\Private$\MyPrivateQueue");&lt;br /&gt;queue.Formatter = new XmlMessageFormatter(&lt;br /&gt;      new string[] {"System.String"});&lt;br /&gt;foreach (Message message in queue)&lt;br /&gt;{&lt;br /&gt;   Console.WriteLine(message.Body);&lt;br /&gt;}&lt;br /&gt;Instead of using the IEnumerable interface, the class MessageEnumerator can be used. MessageEnumerator implements the interface IEnumerator, but has some more features. With the IEnumerable interface, the messages are not removed from the queue. The method RemoveCurrent() of the MessageEnumerator removes the message from the current cursor position of the enumerator.&lt;br /&gt;In the example, the MessageQueue method GetMessageEnumerator() is used to access the MessageEnumerator. With the MessageEnumerator the method MoveNext() takes a peek message by message. The MoveNext() method is overloaded to allow a timespan as an argument. This is one of the big advantages when using this enumerator. Here, the thread can wait until a message arrives in the queue, but only for the specified timespan. The Current property, which is defined by the IEnumerator interface, returns a reference to a message:&lt;br /&gt;MessageQueue queue = new MessageQueue(@".\Private$\MyPrivateQueue");&lt;br /&gt;queue.Formatter = new XmlMessageFormatter(&lt;br /&gt;      new string[] {"System.String"});&lt;br /&gt;&lt;br /&gt;using (MessageEnumerator messages = queue.GetMessageEnumerator())&lt;br /&gt;{&lt;br /&gt;   while (messages.MoveNext(TimeSpan.FromMinutes(30)))&lt;br /&gt;   {&lt;br /&gt;      Message message = messages.Current;&lt;br /&gt;      Console.WriteLine(message.Body);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;Asynchronous Read&lt;br /&gt;The Receive method of the MessageQueue class waits until a message from the queue can be read. To avoid blocking the thread, a timeout can be specified in an overloaded version of the Receive method. To read the message from the queue after the timeout, Receive() must be invoked again. Instead of polling for messages, the asynchronous method BeginReceive() can be called. Before starting the asynchronous read with BeginReceive(), the event ReceiveCompleted should be set. The ReceiveCompleted event requires a ReceiveCompletedEventHandler delegate that references the method that is invoked when a message arrives with the queue and can be read. In the example the method MessageArrived is passed to the ReceivedCompletedEventHandler delegate:&lt;br /&gt;MessageQueue queue = new MessageQueue(@".\Private$\MyPrivateQueue");&lt;br /&gt;queue.Formatter = new XmlMessageFormatter(&lt;br /&gt;      new string[] {"System.String"});&lt;br /&gt;&lt;br /&gt;queue.ReceiveCompleted +=&lt;br /&gt;   new ReceiveComletedEventHandler(MessageArrived);&lt;br /&gt;queue.BeginReceive();&lt;br /&gt;// thread does not wait&lt;br /&gt;The handler method MessageArrived requires two parameters. The first parameter is the origin of the event, the MessageQueue. The second parameter is of type ReceiveCompletedEventArgs that contains the message and the async result. In the example, the method EndReceive() from the queue is invoked to get the result of the asynchronous method, the message:&lt;br /&gt;&lt;br /&gt;public static void MessageArrived(object source,&lt;br /&gt;      ReceiveCompletedEventArgs e)&lt;br /&gt;{&lt;br /&gt;   MessageQueue queue = (MessageQueue)source;&lt;br /&gt;   Message message = queue.EndReceive(e.AsyncResult);&lt;br /&gt;   Console.WriteLine(message.Body);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Visit: http://www.eggheadcafe.com/tutorials/aspnet/923491b3-00ae-4a51-926c-14039007684d/message-queuing-in-cnet.aspx&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-8313803785487250674?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/8313803785487250674/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/message-queuing-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8313803785487250674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8313803785487250674'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/message-queuing-in-net.html' title='Message Queuing in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-7040532254815768454</id><published>2009-05-19T03:10:00.000-07:00</published><updated>2009-05-19T03:13:02.661-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>What is Searialization in .Net</title><content type='html'>Serialization (known as pickling in python) is an easy way to convert an object to a binary representation that can then be e.g. written to disk or sent over a wire.&lt;br /&gt;It's useful e.g. for easy saving of settings to a file.&lt;br /&gt;You can serialize your own classes if you mark them with [Serializable] attribute. This serializes all members of a class, except those marked as [NonSerialized].&lt;br /&gt;.NET offers 2 serializers: binary, SOAP, XML. The difference between binary and SOAP is:&lt;br /&gt;• binary is more efficient (time and memory used)&lt;br /&gt;• binary is completely human-unreadable. SOAP isn't much better.&lt;br /&gt;XML is slightly different:&lt;br /&gt;• it lives in System.Xml.Serialization&lt;br /&gt;• it uses [XmlIgnore] instead of [NonSerialized] and ignores [Serializable]&lt;br /&gt;• it doesn't serialize private class members&lt;br /&gt;An example of serialization/deserialization to a file:&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;using System.Runtime.Serialization;&lt;br /&gt;using System.Runtime.Serialization.Formatters;&lt;br /&gt;using System.Runtime.Serialization.Formatters.Binary;&lt;br /&gt;&lt;br /&gt;[Serializable]&lt;br /&gt;public class MySettings {&lt;br /&gt;    public int screenDx;&lt;br /&gt;    public ArrayList recentlyOpenedFiles;&lt;br /&gt;    [NonSerialized]public string dummy;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Settings {&lt;br /&gt;    const int VERSION = 1;&lt;br /&gt;    static void Save(MySettings settings, string fileName) {&lt;br /&gt;            Stream stream = null;&lt;br /&gt;            try {&lt;br /&gt;                IFormatter formatter = new BinaryFormatter();&lt;br /&gt;                stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);&lt;br /&gt;                formatter.Serialize(stream, VERSION);&lt;br /&gt;                formatter.Serialize(stream, settings);&lt;br /&gt;            } catch {&lt;br /&gt;                // do nothing, just ignore any possible errors&lt;br /&gt;            } finally {&lt;br /&gt;                if (null != stream)&lt;br /&gt;                    stream.Close();&lt;br /&gt;            }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    static MySettings Load(string fileName) {&lt;br /&gt;        Stream stream = null;&lt;br /&gt;        MySettings settings = null;&lt;br /&gt;        try {&lt;br /&gt;            IFormatter formatter = new BinaryFormatter();&lt;br /&gt;            stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None);&lt;br /&gt;            int version = (int)formatter.Deserialize(stream);&lt;br /&gt;            Debug.Assert(version == VERSION);&lt;br /&gt;            settings = (MySettings)formatter.Deserialize(stream);&lt;br /&gt;        } catch {&lt;br /&gt;            // do nothing, just ignore any possible errors&lt;br /&gt;        } finally {&lt;br /&gt;            if (null != stream)&lt;br /&gt;                stream.Close();&lt;br /&gt;        }&lt;br /&gt;        return settings;&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-7040532254815768454?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/7040532254815768454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/what-is-searialization-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7040532254815768454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7040532254815768454'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/what-is-searialization-in-net.html' title='What is Searialization in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-1465980507303832519</id><published>2009-05-15T00:10:00.000-07:00</published><updated>2009-05-15T00:11:39.231-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>How to use FileSystemWatcher in .Net</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Threading;&lt;br /&gt;&lt;br /&gt;namespace PubishApps&lt;br /&gt;{&lt;br /&gt;    public class ClsFileSystemWatcher&lt;br /&gt;    {&lt;br /&gt;    &lt;br /&gt; /************************************************&lt;br /&gt;* Topic : How to use FileSystemWatcher in .Net&lt;br /&gt;* Reference Required: System.IO, System.Threading.&lt;br /&gt;* Author : kalit sikka&lt;br /&gt;* Usage: This class can use to track for filesystem changes on the local machine, a networked drive, and even a remote machine.&lt;br /&gt;* Generally use in window services to track changes in background.&lt;br /&gt;* **********************************************/&lt;br /&gt;&lt;br /&gt;    public  void FileWatcher(string InputDir)&lt;br /&gt;    {    &lt;br /&gt;    using (FileSystemWatcher fsw = new FileSystemWatcher( ))&lt;br /&gt;    {&lt;br /&gt;        fsw.Path = InputDir; // Input Path&lt;br /&gt;        fsw.Filter = @"*.txt"; // Filter for files&lt;br /&gt;        fsw.IncludeSubdirectories = true;&lt;br /&gt;&lt;br /&gt;        fsw.NotifyFilter = NotifyFilters.FileName |&lt;br /&gt;            NotifyFilters.Attributes  |&lt;br /&gt;            NotifyFilters.LastAccess  |&lt;br /&gt;            NotifyFilters.LastWrite   |&lt;br /&gt;            NotifyFilters.Security    |&lt;br /&gt;            NotifyFilters.Size        |&lt;br /&gt;            NotifyFilters.CreationTime|&lt;br /&gt;            NotifyFilters.DirectoryName;&lt;br /&gt;&lt;br /&gt;        fsw.Changed += new FileSystemEventHandler(OnChanged);&lt;br /&gt;        fsw.Created += new FileSystemEventHandler(OnCreated);&lt;br /&gt;        fsw.Deleted += new FileSystemEventHandler(OnDeleted);&lt;br /&gt;        fsw.Renamed += new RenamedEventHandler(OnRenamed);&lt;br /&gt;        fsw.Error += new ErrorEventHandler(OnError);&lt;br /&gt;&lt;br /&gt;        fsw.EnableRaisingEvents = true;&lt;br /&gt;&lt;br /&gt;        string strOldFile = InputDir + "OldFile.txt";&lt;br /&gt;        string strNewFile = InputDir + "CreatedFile.txt";&lt;br /&gt;&lt;br /&gt;        // Making changes in existing file&lt;br /&gt;        &lt;br /&gt;        using (FileStream stream = File.Open(strOldFile, FileMode.Append))&lt;br /&gt;        {&lt;br /&gt;            StreamWriter sw = new StreamWriter(stream);&lt;br /&gt;            sw.Write("Appending new line in Old File");&lt;br /&gt;            sw.Flush();&lt;br /&gt;            sw.Close();&lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Writing new file on FileSystem&lt;br /&gt;        &lt;br /&gt;        using (FileStream stream = File.Create(strNewFile))&lt;br /&gt;        {&lt;br /&gt;            StreamWriter sw = new StreamWriter(stream);&lt;br /&gt;            sw.Write("Writing First line into the File");&lt;br /&gt;            sw.Flush();&lt;br /&gt;            sw.Close();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        File.Delete(strOldFile);&lt;br /&gt;        File.Delete(strNewFile);&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;        // Minimum time given to event handler to track new events raised by the filesystem.&lt;br /&gt;      &lt;br /&gt;        Thread.Sleep(1000);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;    public static void OnChanged(object source, FileSystemEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine("File " + e.FullPath + " :" + e.ChangeType);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static void OnDeleted(object source, FileSystemEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine("File " + e.FullPath + " :" + e.ChangeType);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static void OnCreated(object source, FileSystemEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine("File " + e.FullPath + " :" + e.ChangeType);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static void OnRenamed(object source, RenamedEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine("File " + e.OldFullPath + " [Changed to] " + e.FullPath);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static void OnError(object source, ErrorEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine("Error " + e.ToString( ));&lt;br /&gt;    }&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            ClsFileSystemWatcher FSysWatcher = new ClsFileSystemWatcher();&lt;br /&gt;            FSysWatcher.FileWatcher(@"D:\kalit\");&lt;br /&gt;        }&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-1465980507303832519?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/1465980507303832519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-to-use-filesystemwatcher-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/1465980507303832519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/1465980507303832519'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-to-use-filesystemwatcher-in-net.html' title='How to use FileSystemWatcher in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-4809277270547246393</id><published>2009-05-06T00:13:00.000-07:00</published><updated>2009-05-06T00:14:52.329-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOPS'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Attributes of OOPS in .Net</title><content type='html'>User-Defined Value Types (Structures)&lt;br /&gt;Applications often require types to encapsulate essentially numeric quantities such as currencies, screen coordinates, and temperatures, &lt;br /&gt;which are not represented by the available primitive types. &lt;br /&gt;Using classes in these scenarios would be like using a hammer to crack a nut; the run-time overhead for garbage-collecting these simple objects would be unnecessarily high.&lt;br /&gt;&lt;br /&gt;The .NET Framework provides user-definable value types as a solution to this problem. &lt;br /&gt;In C#, a value type is written as a struct. Remember that like value types, instances of structs are stored wherever they are used.&lt;br /&gt; using System;&lt;br /&gt;&lt;br /&gt;   struct Money&lt;br /&gt;   {&lt;br /&gt;     // private instance field&lt;br /&gt;     private int centsAmount;&lt;br /&gt;&lt;br /&gt;     // private class field&lt;br /&gt;     private const string currencySymbol = "$";&lt;br /&gt;&lt;br /&gt;     // public constructor&lt;br /&gt;     public Money(int dollars, int cents)&lt;br /&gt;     {&lt;br /&gt;       centsAmount = (dollars * 100) + cents;&lt;br /&gt;     }&lt;br /&gt;     // another public constructor&lt;br /&gt;     public Money(double amount)&lt;br /&gt;     {&lt;br /&gt;       centsAmount = (int)((amount * 100.0) + 0.5);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   class MyClass&lt;br /&gt;   {&lt;br /&gt;     static void Main()&lt;br /&gt;     {&lt;br /&gt;       Money freebie;&lt;br /&gt;       Money salary = new Money(20000, 0);&lt;br /&gt;       Money carPrice = new Money(34999.95);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Although structures cannot explicitly inherit from an arbitrary class, they can implement interfaces. For example, it is quite common to implement standard .NET Framework interfaces such as IComparable, which allows us to specify how objects should be compared, and so enables sorting. Value types will often implement this to interoperate well with other classes in the .NET Framework.&lt;br /&gt;&lt;br /&gt;We'll be covering interfaces in more detail later in this chapter, but the following preview demonstrates how easily we can change our Money value type to implement an interface, and override the ToString() method inherited from System.Object:&lt;br /&gt;&lt;br /&gt;     // value_type_inheritance.cs&lt;br /&gt;     using System;&lt;br /&gt;&lt;br /&gt;     struct Money : IComparable&lt;br /&gt;     {&lt;br /&gt;       // private fields&lt;br /&gt;       private int centsAmount;&lt;br /&gt;       private const string currencySymbol = "$";&lt;br /&gt;&lt;br /&gt;       // public constructors&lt;br /&gt;       public Money(int dollars, int cents)&lt;br /&gt;       {&lt;br /&gt;         centsAmount = (dollars * 100) + cents;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       public Money(double amount)&lt;br /&gt;       {&lt;br /&gt;         centsAmount = (int)((amount * 100.0) + 0.5);&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       // compare with another Money&lt;br /&gt;       public int CompareTo(object other)&lt;br /&gt;       {&lt;br /&gt;         Money m2 = (Money)other;&lt;br /&gt;         if (centsAmount &lt; m2.centsAmount)&lt;br /&gt;           return -1;&lt;br /&gt;         else if (centsAmount == m2.centsAmount)&lt;br /&gt;           return 0;&lt;br /&gt;         else&lt;br /&gt;           return 1;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;     // return value as a string&lt;br /&gt;     public override string ToString()&lt;br /&gt;     {&lt;br /&gt;       return currencySymbol + (centsAmount / 100.0).ToString();&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Enumerations&lt;br /&gt;Enumerations are .NET value types that represent integral types with a limited set of permitted values. They may also be used to map bit flags onto an integer type to allow a convenient way to represent a combination of options using a single variable. Enumerations are present in many programming languages, but in .NET they are also object-oriented. This means that developers now have access to additional features, which are not present in other languages.&lt;br /&gt;&lt;br /&gt;Enumerated Types&lt;br /&gt;To declare an enumerated type, we use the enum keyword and specify symbolic names to represent the allowable values. We can also specify an underlying integral data type to be used for the enumeration (byte, short, int, or long), and optionally assign a specific number to each of the names.&lt;br /&gt;&lt;br /&gt;The following example, enumerations.cs, declares a simple enumeration to represent medals in a competition:&lt;br /&gt;&lt;br /&gt;   // enumerations.cs&lt;br /&gt;   using System;&lt;br /&gt;&lt;br /&gt;   enum Medal : short&lt;br /&gt;   {&lt;br /&gt;     Gold,&lt;br /&gt;     Silver,&lt;br /&gt;     Bronze&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;Enumerations inherit implicitly from System.Enum, and so inherit all of its members. Having defined an enumerated type, we can use it in our code as follows:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   class MyClass&lt;br /&gt;   {&lt;br /&gt;     static void Main()&lt;br /&gt;     {&lt;br /&gt;       Medal myMedal = Medal.Bronze;&lt;br /&gt;       Console.WriteLine("My medal: " + myMedal.ToString());&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;Medal[] medals = (Medal[])Enum.GetValues(typeof(Medal));&lt;br /&gt;         foreach (Medal m in medals)&lt;br /&gt;         {&lt;br /&gt;           Console.WriteLine("{0:D}\t{1:G}", m, m);&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;class MyClass&lt;br /&gt;   {&lt;br /&gt;     // Field (usually private, for encapsulation)&lt;br /&gt;     private int aField;&lt;br /&gt;&lt;br /&gt;     // Property (usually public, for ease of use)&lt;br /&gt;     public int AProperty&lt;br /&gt;     {&lt;br /&gt;       get { return aField; }&lt;br /&gt;       set { aField = value; }&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     // Constant (class-wide, read-only field)&lt;br /&gt;     private const int aConstant = 43;&lt;br /&gt;&lt;br /&gt;     // Delegate (defines a method signature)&lt;br /&gt;     public delegate void ADelegate(int aParameter);&lt;br /&gt;&lt;br /&gt;     // Event (to alert event receiver objects)&lt;br /&gt;     public event ADelegate AnEvent;&lt;br /&gt;&lt;br /&gt;     // Method&lt;br /&gt;     public void AMethod()&lt;br /&gt;     {&lt;br /&gt;       // Method implementation code&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     // Instance constructor (to initialize new objects)&lt;br /&gt;     public MyClass(int aValue)&lt;br /&gt;     {&lt;br /&gt;       aField = aValue;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     // Destructor method (to tidy up unmanaged resources)&lt;br /&gt;     ~MyClass()&lt;br /&gt;     {&lt;br /&gt;       // Finalization code&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     // Nested class definition&lt;br /&gt;     private class aNestedClass&lt;br /&gt;     {&lt;br /&gt;       // class definition&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;Properties&lt;br /&gt;Properties represent state in a class. However, properties are quite different from fields. Whereas a field stores data, a property provides a specific access point to that data. Properties extend the concept of the field by being able to restrict the incoming values and provide read-only and write-only data members.&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;   public class Account&lt;br /&gt;   {&lt;br /&gt;     private double balance;&lt;br /&gt;     public double Balance&lt;br /&gt;     {&lt;br /&gt;       get&lt;br /&gt;       {&lt;br /&gt;         return balance;&lt;br /&gt;       }&lt;br /&gt;       set&lt;br /&gt;       {&lt;br /&gt;         if (value &lt; 0)&lt;br /&gt;             throw&lt;br /&gt;             new ArgumentOutOfRangeException("value","Balance must&lt;br /&gt;                                              be greater than 0");&lt;br /&gt;         balance=value;&lt;br /&gt;       }&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;Static Type Members&lt;br /&gt;The fields, properties, and methods we have seen so far in this chapter are accessible only with a reference to an instance of a class. However, not all functionality is best implemented tied to an instance of a class. .NET allows us to define type members that are callable directly from the class without requiring an instance of the class to be created. Fields, methods, and properties can all be declared in this fashion.&lt;br /&gt;&lt;br /&gt;Static type members are useful if a particular action is not tied to an instance of the class, but is functionality that can be used as a standalone. For example, a Time class may define a GetCurrentTime() method that returns the current system clock time. Creating an instance of Time just to call GetCurrentTime() is not ideal since all classes would return the same value. Since this method is general to the Time class and is not specific to each instance, it is best implemented as a static member.&lt;br /&gt;&lt;br /&gt;Static type members are commonplace with the .NET base class library. A trivial example of a static type member can be found with the System.DateTime class. System.DateTime.Now is a static function returning the system date, as seen in static_time_example.cs. Note that the DateTime class is used directly; we do not need to create an instance of DateTime to call the Now type member. The Now property within the DateTime class is declared as static:&lt;br /&gt;&lt;br /&gt;   using System;&lt;br /&gt;&lt;br /&gt;   public class static_time_example&lt;br /&gt;   {&lt;br /&gt;     [STAThread]&lt;br /&gt;     static void Main(string[] args)&lt;br /&gt;     {&lt;br /&gt;       Console.WriteLine(DateTime.Now);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;Generally speaking, it is useful to think of static members as belonging to classes. Non-static, or instance members belong to objects, or instances of classes. If you'll recall, this is exactly how constants and static read-only fields perform. In fact, a constant is a special type of static field.&lt;br /&gt;&lt;br /&gt;Remember, a field is a storage location for an object's data. A new storage location is created for each instance of an object. It is slightly different if a field is static. A static field denotes exactly one storage location. No matter how many instances of a class are created, there is only ever one copy of a static field.&lt;br /&gt;&lt;br /&gt;Let's make one small change to our Account class to further explore how static fields affect our program. The following code is located in static_bankaccount.cs:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   using System;&lt;br /&gt;&lt;br /&gt;   public class Account&lt;br /&gt;   {&lt;br /&gt;     private static double balance;&lt;br /&gt;&lt;br /&gt;     public double Balance&lt;br /&gt;     {&lt;br /&gt;       get&lt;br /&gt;       {&lt;br /&gt;         return balance;&lt;br /&gt;       }&lt;br /&gt;         set&lt;br /&gt;       {&lt;br /&gt;         balance=value;&lt;br /&gt;       }&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   class AtTheBank&lt;br /&gt;   {&lt;br /&gt;     [STAThread]&lt;br /&gt;     static void Main(string[] args)&lt;br /&gt;     {&lt;br /&gt;       Account mySavings= new Account();&lt;br /&gt;       Account myChecking=new Account();&lt;br /&gt;&lt;br /&gt;       mySavings.Balance=500;&lt;br /&gt;&lt;br /&gt;       Console.WriteLine("Savings balance: " + mySavings.Balance);&lt;br /&gt;       Console.WriteLine("Checking balance: " + myChecking.Balance);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;The only change we've made to the Account class is in how we define the balance field:&lt;br /&gt;&lt;br /&gt;      private static double balance;&lt;br /&gt;&lt;br /&gt;However, while this change is small, the corresponding effect on the program is quite noticeable. Look again at the two instances of Account, mySavings and myChecking:&lt;br /&gt;&lt;br /&gt;   Account mySavings= new Account();&lt;br /&gt;   Account myChecking=new Account();&lt;br /&gt;&lt;br /&gt;   mySavings.Balance=500;&lt;br /&gt;&lt;br /&gt;   Console.WriteLine("Savings balance: " + mySavings.Balance);&lt;br /&gt;   Console.WriteLine("Checking balance: " + myChecking.Balance);&lt;br /&gt;&lt;br /&gt;If balance were an instance variable, then mySavings and myChecking would each have their own balance field. We would expect that the output of the above program would show that the mySavings instance had a balance of 500 while myChecking only had the default value of 0. However, balance is not an instance field. Rather, it is a static field. Because of this, the value of balance is shared across all instances of Account.&lt;br /&gt;&lt;br /&gt;If a method is declared as static, then that method will perform an action on the class, not an instance of the class. A static member can only access and modify static fields. Let's modify the account one more time to show off the use of a static method. The following code is in static_bankaccount2.cs:&lt;br /&gt;&lt;br /&gt;   using System;&lt;br /&gt;&lt;br /&gt;   public class Account&lt;br /&gt;   {&lt;br /&gt;     private static double balance;&lt;br /&gt;&lt;br /&gt;     public double Balance&lt;br /&gt;     {&lt;br /&gt;       //...omitted for brevity&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public static void addTen()&lt;br /&gt;     {&lt;br /&gt;       balance=balance+10;&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   class AtTheBank&lt;br /&gt;   {&lt;br /&gt;     [STAThread]&lt;br /&gt;     static void Main(string[] args)&lt;br /&gt;     {&lt;br /&gt;       Account mySavings= new Account();&lt;br /&gt;       Account myChecking=new Account();&lt;br /&gt;&lt;br /&gt;       mySavings.Balance=500;&lt;br /&gt;       Account.addTen();&lt;br /&gt;&lt;br /&gt;       Console.WriteLine("Savings balance: " + mySavings.Balance);&lt;br /&gt;       Console.WriteLine("Checking balance: " + myChecking.Balance);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;Static methods act on the class, not the instances of the class. Static methods can access static fields, static properties, and other static methods. As such, you cannot call AddTen() through the mySavings or myChecking instances of the Account class. Rather, you must make the call directly against the Account class. However, as you can see from the output, the call does still affect the balance of every instance. This is because AddTen() adds to the static balance field. Here is the output of the above program:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   C:\Class Design\Ch 02&gt;static_bankaccount2.exe&lt;br /&gt;   Savings balance: 500&lt;br /&gt;   Checking balance: 500&lt;br /&gt;   Savings balance: 510&lt;br /&gt;   Checking balance: 510&lt;br /&gt;&lt;br /&gt;Care must be taken when using static methods and fields. Only fields that truly must be shared across all instances should be marked as static. Similarly, only methods and properties that must act on static fields should be marked as static. An ideal situation to use static methods and fields is in conjunction with the read-only attribute.&lt;br /&gt;&lt;br /&gt;Passing by Reference&lt;br /&gt;Passing arguments by reference involves copying a reference to the data instead of the data itself. We think of this as if we are passing a pointer to the location in memory where the data is to the method. Both the client code and the method hold separate references to the same data. Because of this, changes made to the parameter by the method are visible to the client code. The changes a method makes to a parameter that can affect the client code are called side effects. When an argument is passed by reference, think of the parameter as an alias to the argument.&lt;br /&gt;&lt;br /&gt;What actually happens is that the value is copied in to the method, just as it is when passed by value; when the method terminates, the value is copied back out again into the location from which it came, along with any changes that have been made to the value in the course of the method executing.&lt;br /&gt;&lt;br /&gt;Passing an argument by reference requires the use of the additional ref keyword in both the method declaration, and the calling client code. Failure to use the ref keyword in the calling program results in a compile-time error:&lt;br /&gt;&lt;br /&gt;Argument 'n': cannot convert from '&lt;type&gt;' to 'ref &lt;type&gt;'.&lt;br /&gt;&lt;br /&gt;The ref keyword overrides the default pass by value behavior. The following example demonstrates passing data by reference:&lt;br /&gt;&lt;br /&gt;   using System;&lt;br /&gt;&lt;br /&gt;   namespace parameter_types&lt;br /&gt;   {&lt;br /&gt;     public class Calculator&lt;br /&gt;     {&lt;br /&gt;       public static decimal CalculateInterest(ref decimal balance)&lt;br /&gt;       {&lt;br /&gt;         decimal interest = (decimal)45.11;&lt;br /&gt;         balance = balance + interest;&lt;br /&gt;         return (balance);&lt;br /&gt;       }&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     class BatchRun&lt;br /&gt;     {&lt;br /&gt;       static void Main()&lt;br /&gt;       {&lt;br /&gt;         decimal balance = (decimal)4566.54;&lt;br /&gt;&lt;br /&gt;         Console.WriteLine("Balance = " + balance);&lt;br /&gt;         Console.WriteLine("Balance + Interest = " +&lt;br /&gt;             Calculator.CalculateInterest(ref balance));&lt;br /&gt;         Console.WriteLine("Balance = " + balance);&lt;br /&gt;       }&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;Output Parameters&lt;br /&gt;Output parameters solve the problem of getting a method to simulate the manipulation and passing back of more than one value. Similar to ref parameters, output parameters are also passed by reference and the out parameter also behaves like an alias to the argument, but there is one subtle and important difference to ref arguments, and that is that:&lt;br /&gt;&lt;br /&gt; Important  Arguments passed by reference using the out keyword do not have to be initialized before being passed to the method.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;By implication, if an argument has no value (or if it is a null reference), then the method cannot inadvertently do any harm to the argument. Output parameters are also considered unassigned within a method; methods with out parameters must therefore initialize all out parameters before the method returns.&lt;br /&gt;&lt;br /&gt;The following example parameter_types.cs demonstrates passing data by reference using out parameters:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   using System;&lt;br /&gt;&lt;br /&gt;   public class Calculator&lt;br /&gt;   {&lt;br /&gt;     public static decimal CalculateInterest(out decimal balance)&lt;br /&gt;     {&lt;br /&gt;       decimal interest = (decimal)45.11;&lt;br /&gt;       balance = (decimal)4566.54;&lt;br /&gt;       balance += interest;&lt;br /&gt;       return (balance);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   class BatchRun&lt;br /&gt;   {&lt;br /&gt;     static void Main()&lt;br /&gt;     {&lt;br /&gt;       decimal balance;&lt;br /&gt;&lt;br /&gt;       Console.WriteLine("Balance + Interest = " +&lt;br /&gt;           Calculator.CalculateInterest(out balance));&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;   class MSILMethods&lt;br /&gt;   {&lt;br /&gt;     static void Main()&lt;br /&gt;     {&lt;br /&gt;       int result = 0;&lt;br /&gt;       int total;&lt;br /&gt;       int net = 0;&lt;br /&gt;&lt;br /&gt;       MethodExamples examples = new MethodExamples();&lt;br /&gt;&lt;br /&gt;       result = examples.ByValueMethod(7);&lt;br /&gt;       examples.ByRefMethod(ref result);&lt;br /&gt;       examples.OutputMethod(out total, result);&lt;br /&gt;       result = result + examples.OverloadMethod(total);&lt;br /&gt;       total = examples.OverloadMethod(result, total);&lt;br /&gt;       net = examples.ParamsMethod(result, total);&lt;br /&gt;&lt;br /&gt;       Console.WriteLine(net);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   class MethodExamples&lt;br /&gt;   {&lt;br /&gt;     public int ByValueMethod(int a)&lt;br /&gt;     {&lt;br /&gt;       return a++;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public void ByRefMethod(ref int b)&lt;br /&gt;     {&lt;br /&gt;       b = b * 2;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public void OutputMethod(out int c, int d)&lt;br /&gt;     {&lt;br /&gt;       c = d / 4;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public int OverloadMethod(int e)&lt;br /&gt;     {&lt;br /&gt;       return e + 2;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public int OverloadMethod(int e, int f)&lt;br /&gt;     {&lt;br /&gt;       return e + f;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public int ParamsMethod(params int[] g)&lt;br /&gt;     {&lt;br /&gt;       int total = 0;&lt;br /&gt;&lt;br /&gt;       foreach(int num in g)&lt;br /&gt;       {&lt;br /&gt;         total = total + num;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       return total + 1;&lt;br /&gt;     }&lt;br /&gt;   }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-4809277270547246393?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/4809277270547246393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/attributes-of-oops-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/4809277270547246393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/4809277270547246393'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/attributes-of-oops-in-net.html' title='Attributes of OOPS in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-1165716819595226446</id><published>2009-05-05T02:28:00.000-07:00</published><updated>2009-05-05T02:30:02.737-07:00</updated><title type='text'>How to Read text file as database</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data.OleDb;&lt;br /&gt;using System.Data;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;namespace PubishApps&lt;br /&gt;{&lt;br /&gt;    public class ReadTextFileAsDB&lt;br /&gt;    {&lt;br /&gt;/************************************************&lt;br /&gt;* Topic : How to Read text file as database&lt;br /&gt;* Use : Client code could implement DB-Query on text file.&lt;br /&gt;* Author : kalit sikka&lt;br /&gt;* **********************************************/&lt;br /&gt;&lt;br /&gt;        OleDbConnection oConnection = new OleDbConnection();&lt;br /&gt;&lt;br /&gt;        private bool OpenConnection(string InputTextFileName)&lt;br /&gt;        {&lt;br /&gt;            if(!string.IsNullOrEmpty(InputTextFileName))&lt;br /&gt;            {&lt;br /&gt;                oConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"+InputTextFileName+"'; Extended Properties=text;HDR=yes;FMT=Delimited";&lt;br /&gt;                oConnection.Open();&lt;br /&gt;&lt;br /&gt;                if(oConnection.State == System.Data.ConnectionState.Open)&lt;br /&gt;                    return true;&lt;br /&gt;                else&lt;br /&gt;                    return false;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return false;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void BindingDataToGridView(string InputTextFileName, string Query, DataSet ds)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                OpenConnection(InputTextFileName);&lt;br /&gt;&lt;br /&gt;                // Create the data adapter to retrieve all rows from text file.&lt;br /&gt;                OleDbDataAdapter da =&lt;br /&gt;                    new OleDbDataAdapter(Query, oConnection);&lt;br /&gt;                &lt;br /&gt;                // Create and fill the table.&lt;br /&gt;                DataSet dt = new DataSet("MyData");&lt;br /&gt;                da.Fill(dt);&lt;br /&gt;                ds = dt.Copy();&lt;br /&gt;&lt;br /&gt;                // Bind the default view of the table to the grid.&lt;br /&gt;             //   DBview.DataSource = dt.DefaultView;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            }catch(Exception ex)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("Error Occured: "+ ex.Message);&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                if(oConnection.State == System.Data.ConnectionState.Open)&lt;br /&gt;                {&lt;br /&gt;                    oConnection.Close();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;       &lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-1165716819595226446?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/1165716819595226446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-to-read-text-file-as-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/1165716819595226446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/1165716819595226446'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-to-read-text-file-as-database.html' title='How to Read text file as database'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-8687227048125815300</id><published>2009-05-05T02:20:00.000-07:00</published><updated>2009-05-05T02:26:37.207-07:00</updated><title type='text'>How Export Data from DataGrid to Excel</title><content type='html'>In-line Code:&lt;br /&gt;&lt;br /&gt;"http://www.w3.org/1999/xhtml" &gt;&lt;br /&gt;"server"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Top of Form&lt;br /&gt;"form1" runat="server"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"Table" AlternatingRowStyle-BackColor="Lavender" PageSize="10" CellPadding="4" runat="server" AllowPaging="True" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" ForeColor="Black"&gt;&lt;br /&gt;"TopAndBottom" /&gt;&lt;br /&gt;"#CCCCCC" /&gt;&lt;br /&gt;"White" /&gt;&lt;br /&gt;"#000099" Font-Bold="True" ForeColor="White" /&gt;&lt;br /&gt;"Left" BackColor="#CCCCCC" ForeColor="Black" /&gt;&lt;br /&gt;"Black" Font-Bold="True" ForeColor="White" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"BtnExport" runat="server" OnClick="BtnExport_Click"&lt;br /&gt;Text="Export_Data_To_Excel" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Bottom of Form&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Code-Behind:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Data.OracleClient;&lt;br /&gt;&lt;br /&gt;public partial class ExportGridViewDataIntoExcel : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;OracleConnection oOrcCon = new OracleConnection();&lt;br /&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;if(!IsPostBack)&lt;br /&gt;BindDataToGrid(GetDataSetFromSource()); // Binding Data to the Table&lt;br /&gt;}&lt;br /&gt;protected void BtnExport_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;string FileName = "ExportedExcel.xls";&lt;br /&gt;Response.Clear();&lt;br /&gt;Response.AddHeader("content-disposition", "attachment;filename="+FileName+"");&lt;br /&gt;Response.Charset = "";&lt;br /&gt;&lt;br /&gt;Response.Cache.SetCacheability(HttpCacheability.NoCache);&lt;br /&gt;Response.ContentType = "application/vnd.xls";&lt;br /&gt;System.IO.StringWriter oWriter = new System.IO.StringWriter();&lt;br /&gt;System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(oWriter);&lt;br /&gt;Table.RenderControl(htmlWrite);&lt;br /&gt;Response.Write(oWriter.ToString());&lt;br /&gt;Response.End();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Property for setting ConnectionString&lt;br /&gt;///&lt;br /&gt;private string LocalString&lt;br /&gt;{&lt;br /&gt;get { return @"Password=XXXX;User ID=Intranet;Data Source=XXXX;Persist Security Info=True"; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Open the connection&lt;br /&gt;///&lt;br /&gt;private void OpenConnection()&lt;br /&gt;{&lt;br /&gt;if (oOrcCon.State != ConnectionState.Open &amp;amp;&amp;amp; !string.IsNullOrEmpty(LocalString))&lt;br /&gt;oOrcCon.ConnectionString = LocalString;&lt;br /&gt;oOrcCon.Open();&lt;br /&gt;}&lt;br /&gt;///&lt;br /&gt;/// Close Connection&lt;br /&gt;///&lt;br /&gt;private void CloseConnection()&lt;br /&gt;{&lt;br /&gt;if (oOrcCon.State == ConnectionState.Open)&lt;br /&gt;oOrcCon.Close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Extacting DataSet from resultant of Query&lt;br /&gt;///&lt;br /&gt;///&lt;br /&gt;public System.Data.DataSet GetDataSetFromSource()&lt;br /&gt;{&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;OpenConnection();&lt;br /&gt;string str = @"select * from Project order by Project_Name";&lt;br /&gt;OracleCommand Cmd = new OracleCommand(str, oOrcCon);&lt;br /&gt;OracleDataAdapter apter = new OracleDataAdapter(Cmd);&lt;br /&gt;apter.Fill(ds);&lt;br /&gt;return ds;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;Response.Write("Error in extracting Dataset: " + ex.ToString());&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;CloseConnection();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// Bind to the DataGrid&lt;br /&gt;///&lt;br /&gt;///&lt;br /&gt;private void BindDataToGrid(DataSet ds)&lt;br /&gt;{&lt;br /&gt;if (ds != null)&lt;br /&gt;{&lt;br /&gt;Table.DataSource = ds;&lt;br /&gt;Table.DataBind();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public override void VerifyRenderingInServerForm(Control Table)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-8687227048125815300?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/8687227048125815300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-export-data-from-datagrid-to-excel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8687227048125815300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/8687227048125815300'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/how-export-data-from-datagrid-to-excel.html' title='How Export Data from DataGrid to Excel'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-9116110757282712783</id><published>2009-05-01T05:16:00.000-07:00</published><updated>2009-05-01T05:17:18.554-07:00</updated><title type='text'>Introduction to LINQ in .Net</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;namespace PubishApps&lt;br /&gt;{&lt;br /&gt;public class IntroWithLINQ&lt;br /&gt;{&lt;br /&gt;/************************************************&lt;br /&gt;* Topic : Introduction to LINQ in .Net&lt;br /&gt;* Reference Required: System.Linq.&lt;br /&gt;* Author : kalit sikka&lt;br /&gt;* Summary: This article include different methods to show some simple features of LINQ that could make a life of a developer quit easlier in his day-to-day work.&lt;br /&gt;* **********************************************/&lt;br /&gt;public List&lt;developer&gt; GetDeveloperList()&lt;br /&gt;{&lt;br /&gt;List&lt;developer&gt; oList = new List&lt;developer&gt;();&lt;br /&gt;oList.Add(new Developer(1001, "Sri Ram", Designation.Project_Lead, 10));&lt;br /&gt;oList.Add(new Developer(1020, "Amit Narang", Designation.Team_Lead, 8));&lt;br /&gt;oList.Add(new Developer(1056, "Mohit singh", Designation.Sr_Software_Engineer, 7));&lt;br /&gt;oList.Add(new Developer(1081, "Kalit Sikka", Designation.Sr_Software_Engineer, 6));&lt;br /&gt;oList.Add(new Developer(1102, "Sunil Mittal", Designation.Software_Engineer, 4));&lt;br /&gt;oList.Add(new Developer(1106, "Jaswinder saini", Designation.Software_Engineer, 3));&lt;br /&gt;oList.Add(new Developer(1108, "Varinder Pal", Designation.Software_Engineer, 3));&lt;br /&gt;return oList;&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Simple LINQ method using where clause&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void Linq_WhereClause() {&lt;br /&gt;int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };&lt;br /&gt;var lowNums =&lt;br /&gt;from n in numbers&lt;br /&gt;where n &lt; 5&lt;br /&gt;select n;&lt;br /&gt;Console.WriteLine("Numbers &lt; 5:");&lt;br /&gt;foreach (var x in lowNums) {&lt;br /&gt;Console.WriteLine(x);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Using where clause on List object&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void ListWithWhere()&lt;br /&gt;{&lt;br /&gt;List&lt;developer&gt; oDeveloper = GetDeveloperList();&lt;br /&gt;var Experienced =&lt;br /&gt;from d in oDeveloper&lt;br /&gt;where d.Experience &gt; 5&lt;br /&gt;select d;&lt;br /&gt;Console.WriteLine("Experienced Developers");&lt;br /&gt;foreach (var Developer in Experienced) {&lt;br /&gt;Console.WriteLine(string.Format("Name {0} - Experience {1}", Developer.Name, Developer.Experience));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Using where clause and And clause on List object&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void ListWithWhereClause_AndClause() {&lt;br /&gt;List&lt;developer&gt; oDeveloper = GetDeveloperList();&lt;br /&gt;var ExperiencedSeniorDeveloper =&lt;br /&gt;from d in oDeveloper&lt;br /&gt;where d.Experience &gt; 5 &amp;amp;&amp;amp; d.eDesgination == Designation.Sr_Software_Engineer&lt;br /&gt;select d;&lt;br /&gt;Console.WriteLine("Senior Experienced Developers");&lt;br /&gt;foreach (var Developer in ExperiencedSeniorDeveloper) {&lt;br /&gt;Console.WriteLine(string.Format("Name {0} - Experience {1} and Desgination {2}", Developer.Name, Developer.Experience, Developer.eDesgination));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Using Lambda in Linq on List&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void LinqWithLambda() {&lt;br /&gt;List&lt;developer&gt; oDeveloper = GetDeveloperList();&lt;br /&gt;//Lambda expressions allow us to write functions that can be passed&lt;br /&gt;//as arguments to methods, for example, to supply predicates for&lt;br /&gt;//subsequent evaluation.&lt;br /&gt;var MaxExperience = oDeveloper.Where(x =&gt; x.Experience &gt; 5).OrderBy(x =&gt; x);&lt;br /&gt;Console.WriteLine("Most Experienced Developer");&lt;br /&gt;foreach (var Developer in MaxExperience) {&lt;br /&gt;Console.WriteLine(string.Format("Name {0} - Experience {1} and Desgination {2}", Developer.Name, Developer.Experience, Developer.eDesgination));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Add info into List object&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void AddValuesIntoList() {&lt;br /&gt;List&lt;developer&gt; oDeveloper = GetDeveloperList();&lt;br /&gt;var AddOneYearofTrainingInExperience =&lt;br /&gt;from d in oDeveloper&lt;br /&gt;select d.Experience+1;&lt;br /&gt;Console.WriteLine("Extended Experienced");&lt;br /&gt;foreach (var Developer in AddOneYearofTrainingInExperience) {&lt;br /&gt;Console.WriteLine(string.Format("Name {0} - Experience {1}", Developer.Name, Developer.Experience));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Changing Case&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void ChangeTheCaseOfText() {&lt;br /&gt;string[] words = { "aMit", "BalWinDer", "cHeRry", "haRRY", "NaraGh" };&lt;br /&gt;var upperLowerWords =&lt;br /&gt;from w in words&lt;br /&gt;select new {Upper = w.ToUpper(), Lower = w.ToLower()};&lt;br /&gt;foreach (var ul in upperLowerWords) {&lt;br /&gt;Console.WriteLine("Uppercase_Names: {0}, Lowercase_Names: {1}", ul.Upper, ul.Lower);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Giving Alias name to fields&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void GivingAliasNames()&lt;br /&gt;{&lt;br /&gt;List&lt;developer&gt; oDeveloper = GetDeveloperList();&lt;br /&gt;var ChangeNames =&lt;br /&gt;from d in oDeveloper&lt;br /&gt;select new {Developer_Name = d.Name, Developer_Desg = d.eDesgination};&lt;br /&gt;Console.WriteLine("Developer Details");&lt;br /&gt;foreach (var Developer in ChangeNames)&lt;br /&gt;{&lt;br /&gt;Console.WriteLine(string.Format("Name {0} - Desgination {1}", Developer.Developer_Name, Developer.Developer_Desg));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Getting values from Differnet arrays&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void GetValueFromArrays() {&lt;br /&gt;int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };&lt;br /&gt;int[] numbersB = { 1, 3, 5, 7, 8 };&lt;br /&gt;var pairs =&lt;br /&gt;from a in numbersA&lt;br /&gt;from b in numbersB&lt;br /&gt;where a &lt; b&lt;br /&gt;select new {a, b};&lt;br /&gt;Console.WriteLine("Pairs where a &lt; b:");&lt;br /&gt;foreach (var pair in pairs) {&lt;br /&gt;Console.WriteLine("{0} is less than {1}", pair.a, pair.b);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Skipping the values from the collection&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void Linq22() {&lt;br /&gt;int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };&lt;br /&gt;var allButFirst4Numbers = numbers.Skip(4);&lt;br /&gt;Console.WriteLine("All but first 4 numbers:");&lt;br /&gt;foreach (var n in allButFirst4Numbers) {&lt;br /&gt;Console.WriteLine(n);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// TakeWhile to return elements starting from the&lt;br /&gt;/// beginning of the array until a number is hit that is not less than 5&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void Linq2TakeWhile() {&lt;br /&gt;int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };&lt;br /&gt;var firstNumbersLessThan6 = numbers.TakeWhile(n =&gt; n &lt; 5);&lt;br /&gt;Console.WriteLine("First numbers less than 5:");&lt;br /&gt;foreach (var n in firstNumbersLessThan6) {&lt;br /&gt;Console.WriteLine(n);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Sorting Values in List&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void SortingVaues()&lt;br /&gt;{&lt;br /&gt;List&lt;developer&gt; oDeveloper = GetDeveloperList();&lt;br /&gt;var SortByDesgAndExperience =&lt;br /&gt;from d in oDeveloper&lt;br /&gt;orderby d.eDesgination, d.Experience descending&lt;br /&gt;select d;&lt;br /&gt;Console.WriteLine("Sorted Data");&lt;br /&gt;foreach (var Developer in SortByDesgAndExperience) {&lt;br /&gt;Console.WriteLine(string.Format("Name {0} - Experience {1}", Developer.Name, Developer.Experience));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Getting distinct values from the array&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void DistinctValues() {&lt;br /&gt;int[] vals = { 2, 4, 7, 9, 5, 4, 2, 2 , 2, 3, 5, 5 };&lt;br /&gt;var unique = vals.Distinct();&lt;br /&gt;Console.WriteLine("Distinct Values:");&lt;br /&gt;foreach (var v in unique) {&lt;br /&gt;Console.WriteLine(v);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Union of two arrays&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void UnionLINQ() {&lt;br /&gt;int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };&lt;br /&gt;int[] numbersB = { 1, 3, 5, 7, 8 };&lt;br /&gt;var uniqueNumbers = numbersA.Union(numbersB);&lt;br /&gt;Console.WriteLine("Unique numbers from both arrays:");&lt;br /&gt;foreach (var n in uniqueNumbers) {&lt;br /&gt;Console.WriteLine(n);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// First match from the List&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public void FirstMatch() {&lt;br /&gt;List&lt;developer&gt; oDeveloper = GetDeveloperList();&lt;br /&gt;var FirstMatch =&lt;br /&gt;(from d in oDeveloper&lt;br /&gt;where d.Experience &gt; 2 &amp;amp;&amp;amp; d.eDesgination == Designation.Software_Engineer&lt;br /&gt;select d).First();&lt;br /&gt;Console.WriteLine("FirstMatch");&lt;br /&gt;Console.WriteLine(string.Format("Name {0}", FirstMatch.Name));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public class Developer&lt;br /&gt;{&lt;br /&gt;public int ID;&lt;br /&gt;public string Name;&lt;br /&gt;public Designation eDesgination;&lt;br /&gt;public WorkStatus eWorkStatus;&lt;br /&gt;public double Salary;&lt;br /&gt;public string ProjectManager;&lt;br /&gt;public int Experience;&lt;br /&gt;public Developer(int ID, string Name)&lt;br /&gt;{&lt;br /&gt;this.ID = ID;&lt;br /&gt;this.Name = Name;&lt;br /&gt;}&lt;br /&gt;public Developer(int ID, string Name, Designation eDesgination, int Experience)&lt;br /&gt;{&lt;br /&gt;this.ID = ID;&lt;br /&gt;this.Name = Name;&lt;br /&gt;this.eDesgination = eDesgination;&lt;br /&gt;this.Experience = Experience;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public enum WorkStatus&lt;br /&gt;{&lt;br /&gt;ProjectInHand,&lt;br /&gt;OnBench&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public enum Designation&lt;br /&gt;{&lt;br /&gt;Software_Engineer,&lt;br /&gt;Sr_Software_Engineer,&lt;br /&gt;Team_Lead,&lt;br /&gt;Project_Lead&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-9116110757282712783?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/9116110757282712783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/introduction-to-linq-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/9116110757282712783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/9116110757282712783'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/introduction-to-linq-in-net.html' title='Introduction to LINQ in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-201424843584429958</id><published>2009-05-01T05:01:00.000-07:00</published><updated>2009-05-01T05:02:42.306-07:00</updated><title type='text'>Regular Expression in .Net</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Text.RegularExpressions;&lt;br /&gt;namespace PubishApps&lt;br /&gt;{&lt;br /&gt;/************************************************&lt;br /&gt;* Topic : Usage of RegularExpression in .Net&lt;br /&gt;* Reference System.Text.RegularExpressions.&lt;br /&gt;* Author : kalit sikka&lt;br /&gt;* Summary: This regex helper class is design to provide set of static methods to validate commonly used patterns like Email-ID, URL, IP Address, Social Security number, Zip codes etc.&lt;br /&gt;* You just need to add this .cs file in your project to use any of the method in it.&lt;br /&gt;* For : Personal Blog&lt;br /&gt;* **********************************************/&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// This helper class contain general regex static methods which in today to today coding tasks&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public class RegexHelper&lt;br /&gt;{&lt;br /&gt;public static bool IsValidEmailID(string sEmailID)&lt;br /&gt;{&lt;br /&gt;Regex oEmail =&lt;br /&gt;new Regex(@"^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$");&lt;br /&gt;return oEmail.IsMatch(sEmailID);&lt;br /&gt;}&lt;br /&gt;public static bool IsValidURL(string sUrl)&lt;br /&gt;{&lt;br /&gt;Regex oURL =&lt;br /&gt;new Regex(@"^[a-zA-Z0-9\-\.]+\.(comorgnetmileduCOMORGNETMILEDU)$"); // you add more here like au, in&lt;br /&gt;return oURL.IsMatch(sUrl);&lt;br /&gt;}&lt;br /&gt;public static bool IsValidPhoneNumber(string sPhone)&lt;br /&gt;{&lt;br /&gt;Regex oPhone =&lt;br /&gt;new Regex(@"^[2-9]\d{2}-\d{3}-\d{4}$"); // US Phone - like 800-555-5555  333-444-5555  212-666-1234&lt;br /&gt;return oPhone.IsMatch(sPhone);&lt;br /&gt;}&lt;br /&gt;public static bool IsValidIndianMobile(string sMobile)&lt;br /&gt;{&lt;br /&gt;Regex oMobile =&lt;br /&gt;new Regex(@"^((\+){0,1}91(\s){0,1}(\-){0,1}(\s){0,1}){0,1}98(\s){0,1}(\-){0,1}(\s){0,1}[1-9]{1}[0-9]{7}$"); // Indian Mobile - like +919847444225  +91-98-44111112  98 44111116&lt;br /&gt;return oMobile.IsMatch(sMobile);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static bool IsValidUKMobile(string sMobile)&lt;br /&gt;{&lt;br /&gt;Regex oMobile =&lt;br /&gt;new Regex(@"^07([\d]{3})[(\D\s)]?[\d]{3}[(\D\s)]?[\d]{3}$"); // UK Mobile - like 07976444333  07956-514333  07988-321-213&lt;br /&gt;return oMobile.IsMatch(sMobile);&lt;br /&gt;}&lt;br /&gt;public static bool IsValidUSZipCode(string sZipCode)&lt;br /&gt;{&lt;br /&gt;Regex oZipCode =&lt;br /&gt;new Regex(@"^\d{5}$"); // ZipCode - like 33333  55555  23445&lt;br /&gt;return oZipCode.IsMatch(sZipCode);&lt;br /&gt;}&lt;br /&gt;public static bool IsValidIPAddress(string sIPAddress)&lt;br /&gt;{&lt;br /&gt;Regex oIP =&lt;br /&gt;new Regex(@"^(25[0-5]2[0-4][0-9][0-1]{1}[0-9]{2}[1-9]{1}[0-9]{1}[1-9])\.(25[0-5]2[0-4][0-9][0-1]{1}[0-9]{2}[1-9]{1}[0-9]{1}[1-9]0)\.(25[0-5]2[0-4][0-9][0-1]{1}[0-9]{2}[1-9]{1}[0-9]{1}[1-9]0)\.(25[0-5]2[0-4][0-9][0-1]{1}[0-9]{2}[1-9]{1}[0-9]{1}[0-9])$"); // IP Address - like 127.0.0.1  255.255.255.0  192.168.0.1&lt;br /&gt;return oIP.IsMatch(sIPAddress);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static bool IsValidTime(string sTime)&lt;br /&gt;{&lt;br /&gt;Regex oTime =&lt;br /&gt;new Regex(@"^(20212223[01]dd)(([:][0-5]d){1,2})$");&lt;br /&gt;return oTime.IsMatch(sTime);&lt;br /&gt;}&lt;br /&gt;public static bool Is24HourTimeFormat(string sTime)&lt;br /&gt;{&lt;br /&gt;Regex oTime =&lt;br /&gt;new Regex(@"^(([0-1]?[0-9])([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$"); // like - 12:15  10:26:59  22:01:15 - Seconds are optional here&lt;br /&gt;return oTime.IsMatch(sTime);&lt;br /&gt;}&lt;br /&gt;public static bool Is12HourTimeFormat(string sTime)&lt;br /&gt;{&lt;br /&gt;Regex oTime =&lt;br /&gt;new Regex(@" ^ *(1[0-2][1-9]):[0-5][0-9] *(apAP)(mM) *$"); // like - 12:00am  1:00 PM  12:59 pm&lt;br /&gt;return oTime.IsMatch(sTime);&lt;br /&gt;}&lt;br /&gt;public static bool DataFormat(string sDate)&lt;br /&gt;{&lt;br /&gt;// dd/MM/yyyy format with leap year validations&lt;br /&gt;Regex oDate =&lt;br /&gt;new Regex(@"^(((0[1-9][12]\d3[01])\/(0[13578]1[02])\/((1[6-9][2-9]\d)\d{2}))((0[1-9][12]\d30)\/(0[13456789]1[012])\/((1[6-9][2-9]\d)\d{2}))((0[1-9]1\d2[0-8])\/02\/((1[6-9][2-9]\d)\d{2}))(29\/02\/((1[6-9][2-9]\d)(0[48][2468][048][13579][26])((16[2468][048][3579][26])00))))$");&lt;br /&gt;return oDate.IsMatch(sDate);&lt;br /&gt;}&lt;br /&gt;public static bool IsNumeric(string sNum)&lt;br /&gt;{&lt;br /&gt;// Natural Number&lt;br /&gt;Regex oNum =&lt;br /&gt;new Regex(@"0*[1-9][0-9]*");&lt;br /&gt;return oNum.IsMatch(sNum);&lt;br /&gt;}&lt;br /&gt;public static bool IsAlpha(string sValue)&lt;br /&gt;{&lt;br /&gt;// Alpha value&lt;br /&gt;Regex oValue =&lt;br /&gt;new Regex(@"[^a-zA-Z]");&lt;br /&gt;return oValue.IsMatch(sValue);&lt;br /&gt;}&lt;br /&gt;public static bool IsAlphaNumeric(string strToCheck)&lt;br /&gt;{&lt;br /&gt;Regex oCheck=new Regex("[^a-zA-Z0-9]");&lt;br /&gt;return oCheck.IsMatch(strToCheck);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static bool IsStrongPassword(string sPassword)&lt;br /&gt;{&lt;br /&gt;// Check Password with atleast 8 characters, no more than 15 characters, and must include atleast one upper case letter, one lower case letter, and one numeric digit.&lt;br /&gt;Regex oPassword =&lt;br /&gt;new Regex(@"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}$");&lt;br /&gt;return oPassword.IsMatch(sPassword);&lt;br /&gt;}&lt;br /&gt;public static bool IsSocialSecurityNumber(string sValue)&lt;br /&gt;{&lt;br /&gt;// U.S. social security numbers, within the range of numbers that have been currently allocated&lt;br /&gt;Regex oValue =&lt;br /&gt;new Regex(@"^(?!000)([0-6]\d{2}7([0-6]\d7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}");&lt;br /&gt;return oValue.IsMatch(sValue);&lt;br /&gt;}&lt;br /&gt;public static bool IsVISACreditCard(string sValue)&lt;br /&gt;{&lt;br /&gt;// Validate against a visa card number&lt;br /&gt;Regex oValue =&lt;br /&gt;new Regex(@"^([4]{1})([0-9]{12,15})$");&lt;br /&gt;return oValue.IsMatch(sValue);&lt;br /&gt;}&lt;br /&gt;public static bool IsISBNumber(string sValue)&lt;br /&gt;{&lt;br /&gt;// ISBN validation expression&lt;br /&gt;Regex oValue =&lt;br /&gt;new Regex(@"^\d{9}[\dX]$");&lt;br /&gt;return oValue.IsMatch(sValue);&lt;br /&gt;}&lt;br /&gt;public static bool IsDollarAmount(string sAmt)&lt;br /&gt;{&lt;br /&gt;// Dollar decimal amount with or without dollar sign&lt;br /&gt;Regex oAmt =&lt;br /&gt;new Regex(@"^\$?\d+(\.(\d{2}))?$");&lt;br /&gt;return oAmt.IsMatch(sAmt);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Method to return string array of splitted values from string&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="value"&gt;string value [KabirSachinJohnMarkDavidkevinNash]&lt;/param&gt;&lt;br /&gt;/// &lt;param name="separator"&gt;separator in the string value&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public static string[] mSplitString(string value, string separator)&lt;br /&gt;{&lt;br /&gt;string[] values = new string[25];&lt;br /&gt;if(!string.IsNullOrEmpty(value) &amp;amp;&amp;amp; !string.IsNullOrEmpty(separator))&lt;br /&gt;{&lt;br /&gt;values = System.Text.RegularExpressions.Regex.Split(value, separator);&lt;br /&gt;return values;&lt;br /&gt;}&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// To Remove specfic string from Collection of string&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="strNames"&gt;KabirSachinJohnMarkDavidkevinNash&lt;/param&gt;&lt;br /&gt;/// &lt;param name="sep"&gt;separator in the string value&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public static string mRemoveStringFromCollection(string strNames, string sep, string specificStr)&lt;br /&gt;{&lt;br /&gt;List&lt;string&gt; list = new List&lt;string&gt;();&lt;br /&gt;string strValue = String.Empty;&lt;br /&gt;if (!string.IsNullOrEmpty(strNames))&lt;br /&gt;{&lt;br /&gt;list.AddRange(Regex.Split(strNames, sep));&lt;br /&gt;foreach (string str in list)&lt;br /&gt;{&lt;br /&gt;if (!str.Contains(specificStr))&lt;br /&gt;{&lt;br /&gt;if (string.IsNullOrEmpty(strValue))&lt;br /&gt;{&lt;br /&gt;strValue = str;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;strValue = strValue + sep + str;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;return strValue;&lt;br /&gt;}&lt;br /&gt;return strNames;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-201424843584429958?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/201424843584429958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/regular-expression-in-net.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/201424843584429958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/201424843584429958'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/05/regular-expression-in-net.html' title='Regular Expression in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-5262593194366676004</id><published>2009-01-30T23:07:00.000-08:00</published><updated>2009-01-30T23:08:29.046-08:00</updated><title type='text'>How to upload File on FTP Server in .Net</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Net;&lt;br /&gt;&lt;br /&gt;namespace PubishApps&lt;br /&gt;{&lt;br /&gt;/************************************************&lt;br /&gt;* Topic : How to upload File on FTP Server in .Net&lt;br /&gt;* Reference Required: System.Net.&lt;br /&gt;* Author : kalit sikka&lt;br /&gt;* Summary: using FtpWebRequest Class in System.Net namespace to upload files on local machine to FTP Server.&lt;br /&gt;* **********************************************/&lt;br /&gt;public struct FTPCredentials&lt;br /&gt;{&lt;br /&gt;public string FTPHostID;&lt;br /&gt;public string UserName;&lt;br /&gt;public string Password;&lt;br /&gt;public FTPCredentials(string HostID, string User, string Password)&lt;br /&gt;{&lt;br /&gt;this.FTPHostID = HostID;&lt;br /&gt;this.UserName = User;&lt;br /&gt;this.Password = Password;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public class DataUploadOnFTP&lt;br /&gt;{&lt;br /&gt;private string FTPHostID = string.Empty;&lt;br /&gt;private string UserName = string.Empty;&lt;br /&gt;private string Password = string.Empty;&lt;br /&gt;private string FullPathOfInputFile = string.Empty;&lt;br /&gt;private string FileName = string.Empty;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Constructor&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="Credentials"&gt;FTP Credentials&lt;/param&gt;&lt;br /&gt;/// &lt;param name="FullPathOfFileToUpload"&gt;Full path on Input File&lt;/param&gt;&lt;br /&gt;public DataUploadOnFTP(FTPCredentials Credentials, string FullPathOfFileToUpload)&lt;br /&gt;{&lt;br /&gt;FTPHostID = Credentials.FTPHostID;&lt;br /&gt;UserName = Credentials.UserName;&lt;br /&gt;Password = Credentials.Password;&lt;br /&gt;this.FullPathOfInputFile = FullPathOfFileToUpload;&lt;br /&gt;// Getting only File Name from complete address&lt;br /&gt;this.FileName = System.IO.Path.GetFileName(FullPathOfFileToUpload);&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Method to upload file to FTP Server.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public bool UploadFileOnFTP()&lt;br /&gt;{&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;string FTPHost = "ftp://" + FTPHostID;&lt;br /&gt;string FTPFilePath = Path.Combine(FTPHost, FileName);&lt;br /&gt;FtpWebRequest oFTP = (FtpWebRequest)FtpWebRequest.Create(FTPFilePath);&lt;br /&gt;oFTP.Credentials = new NetworkCredential(UserName, Password);&lt;br /&gt;oFTP.KeepAlive = true;&lt;br /&gt;oFTP.UseBinary = true;&lt;br /&gt;oFTP.Method = WebRequestMethods.Ftp.UploadFile;&lt;br /&gt;FileStream fs = File.OpenRead(FullPathOfInputFile);&lt;br /&gt;byte[] buffer = new byte[fs.Length];&lt;br /&gt;fs.Read(buffer, 0, buffer.Length);&lt;br /&gt;fs.Close();&lt;br /&gt;Stream ftpstream = oFTP.GetRequestStream();&lt;br /&gt;ftpstream.Write(buffer, 0, buffer.Length);&lt;br /&gt;ftpstream.Close();&lt;br /&gt;return true;&lt;br /&gt;}catch(Exception e)&lt;br /&gt;{&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-5262593194366676004?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/5262593194366676004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/how-to-upload-file-on-ftp-server-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/5262593194366676004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/5262593194366676004'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/how-to-upload-file-on-ftp-server-in-net.html' title='How to upload File on FTP Server in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-7221240927685848718</id><published>2009-01-30T04:10:00.001-08:00</published><updated>2009-01-30T04:10:40.606-08:00</updated><title type='text'>Introduction to .Net Framework</title><content type='html'>The Microsoft .Net Framework is a platform that provides tools and technologies you need to build Networked Applications as well as Distributed Web Services and Web Applications. The .Net Framework provides the necessary compile time and run-time foundation to build and run any language that conforms to the &lt;a href="http://vb.net-informations.com/framework/common_language_specification.htm"&gt;Common Language Specification&lt;/a&gt; (CLS).The main two components of .Net Framework are &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) and .Net &lt;a href="http://vb.net-informations.com/framework/framework_class_library.htm"&gt;Framework Class Library&lt;/a&gt; (FCL).&lt;br /&gt;The &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) is the runtime environment of the .Net Framework , that executes and manages all running code like a Virtual Machine. The .Net &lt;a href="http://vb.net-informations.com/framework/framework_class_library.htm"&gt;Framework Class Library&lt;/a&gt; (FCL) is a huge collection of language-independent and type-safe reusable classes. The .Net Framework Class Libraries (FCL) are arranged into a logical grouping according to their functionality and usability is called &lt;a href="http://vb.net-informations.com/framework/namespaces.htm"&gt;Namespaces&lt;/a&gt;. In the following sections describes &lt;a href="http://vb.net-informations.com/framework/How_to_net_framework.htm"&gt;how to .Net Framework&lt;/a&gt; manages the code in compile time and run time.&lt;br /&gt;Microsoft .Net Languages Source Code are compiled into &lt;a href="http://vb.net-informations.com/framework/microsoft_intermediate_language.htm"&gt;Microsoft Intermediate Language&lt;/a&gt; (MSIL). MSIL we can call it as Intermediate Language (IL) or Common Intermediate Language (CIL). Microsoft Intermediate Language (MSIL) is a CPU independent set of instructions that can be converted to the native code. &lt;a href="http://vb.net-informations.com/framework/metadata.htm"&gt;Metadata&lt;/a&gt; also created in the course of compile time with Microsoft Intermediate Language (MSIL) and stored it with the compiled code . Metadata is completely self-describing . Metadata is stored in a file called &lt;a href="http://vb.net-informations.com/framework/assembly_manifest.htm"&gt;Manifest&lt;/a&gt;, and it contains information about the members, types, references and all the other data that the &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) needs for execution.&lt;br /&gt;The Common Language Runtime (CLR) uses &lt;a href="http://vb.net-informations.com/framework/metadata.htm"&gt;metadata&lt;/a&gt; to locate and load classes, generate native code, provide security, and execute &lt;a href="http://vb.net-informations.com/framework/managed_code.htm"&gt;Managed Code&lt;/a&gt;. Both &lt;a href="http://vb.net-informations.com/framework/microsoft_intermediate_language.htm"&gt;Microsoft Intermediate Language&lt;/a&gt; (MSIL) and Metadata assembled together is known as Portable Executable (PE) file. Portable Executable (PE) is supposed to be portable across all 32-bit operating systems by Microsoft &lt;a href="http://vb.net-informations.com/framework/what_is_net_framework.htm"&gt;.Net Framework&lt;/a&gt;.&lt;br /&gt;During the runtime the Common Language Runtime (CLR)'s &lt;a href="http://vb.net-informations.com/framework/just_in_time_compiler.htm"&gt;Just In Time&lt;/a&gt; (JIT) compiler converts the Microsoft Intermediate Language (MSIL) code into native code to the Operating System. The native code is Operating System independent and this code is known as &lt;a href="http://vb.net-informations.com/framework/managed_code.htm"&gt;Managed Code&lt;/a&gt; , that is, the language's functionality is managed by the &lt;a href="http://vb.net-informations.com/framework/what_is_net_framework.htm"&gt;.NET Framework&lt;/a&gt; . The Common Language Runtime (CLR) provides various Just In Time (JIT) compilers, and each works on a different architecture depends on Operating Systems, that means the same &lt;a href="http://vb.net-informations.com/framework/microsoft_intermediate_language.htm"&gt;Microsoft Intermediate Language&lt;/a&gt; (MSIL) can be executed on different Operating Systems. In the following section you can see how &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) functions.&lt;br /&gt;&lt;br /&gt;Common Language Runtime&lt;br /&gt;The Common Language Runtime (CLR) is an Execution Environment . It works as a layer between Operating Systems and the applications written in .Net languages that conforms to the &lt;a href="http://vb.net-informations.com/framework/common_language_specification.htm"&gt;Common Language Specification&lt;/a&gt; (CLS). The main function of Common Language Runtime (CLR) is to convert the &lt;a href="http://vb.net-informations.com/framework/managed_code.htm"&gt;Managed Code&lt;/a&gt; into native code and then execute the Program. The Managed Code compiled only when it needed, that is it converts the appropriate instructions when each function is called. The Common Language Runtime (CLR) 's &lt;a href="http://vb.net-informations.com/framework/just_in_time_compiler.htm"&gt;Just In Time&lt;/a&gt; (JIT) compilation converts Intermediate Language (MSIL) to native code on demand at application run time.&lt;br /&gt;During the execution of the program ,the Common Language Runtime (CLR) manages memory, &lt;a href="http://vb.net-informations.com/framework/threads.htm"&gt;Thread&lt;/a&gt; execution, &lt;a href="http://vb.net-informations.com/framework/garbage_collection.htm"&gt;Garbage Collection&lt;/a&gt; (GC) , &lt;a href="http://vb.net-informations.com/language/vb.net_exceptions.htm"&gt;Exception&lt;/a&gt; Handling, &lt;a href="http://vb.net-informations.com/framework/common_type_system.htm"&gt;Common Type System&lt;/a&gt; (CTS), code safety verifications, and other system services. The CLR ( Common Language Runtime ) defines the Common Type System (CTS), which is a standard type system used by all .Net languages. That means all .NET programming languages uses the same representation for common &lt;a href="http://vb.net-informations.com/language/vb.net_data_types.htm"&gt;Data Types&lt;/a&gt; , so Common Language Runtime (CLR) is a language-independent runtime environment . The Common Language Runtime (CLR) environment is also referred to as a managed environment, because during the execution of a program it also controls the interaction with the Operating System. In the coming section you can see what are the &lt;a href="http://vb.net-informations.com/framework/functions_of_common_language_runtime.htm"&gt;main functions of Common Language Runtime&lt;/a&gt; (CLR).&lt;br /&gt;The &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) is a an Execution Environment . Common Language Runtime (CLR)'s main tasks are to convert the .NET &lt;a href="http://vb.net-informations.com/framework/managed_code.htm"&gt;Managed Code&lt;/a&gt; to native code, manage running code like a Virtual Machine and also controls the interaction with the Operating System.&lt;br /&gt;Common Language Runtime (CLR) manages &lt;a href="http://vb.net-informations.com/framework/threads.htm"&gt;Thread&lt;/a&gt; executions, Memory Management that is allocation of Objects and Buffers , &lt;a href="http://vb.net-informations.com/framework/garbage_collection.htm"&gt;Garbage Collection&lt;/a&gt; (GC) - Clean up the unused Objects and buffers , &lt;a href="http://vb.net-informations.com/language/vb.net_exceptions.htm"&gt;Exception&lt;/a&gt; Handling, &lt;a href="http://vb.net-informations.com/framework/common_type_system.htm"&gt;Common Type System&lt;/a&gt; (CTS) that is all .NET language that conforms to the &lt;a href="http://vb.net-informations.com/framework/common_language_specification.htm"&gt;Common Language Specification&lt;/a&gt; (CLS) have the same primitive &lt;a href="http://vb.net-informations.com/language/vb.net_data_types.htm"&gt;Data Types&lt;/a&gt;, Code safety verifications - code can be verified to ensure type safety, Language integration that is Common Language Runtime (CLR) follow a set of specification called &lt;a href="http://vb.net-informations.com/framework/common_language_specification.htm"&gt;Common Language Specification&lt;/a&gt; (CLS) , this will ensure the interoperability between languages, Integrated security and other system services.&lt;br /&gt;&lt;br /&gt;.Net Framework Class Library (FCL)&lt;br /&gt;The .Net Framework class library (FCL) provides the core functionality of &lt;a href="http://vb.net-informations.com/framework/what_is_net_framework.htm"&gt;.Net Framework&lt;/a&gt; architecture. The .Net Framework Class Library (FCL) includes a huge collection of reusable classes, interfaces, and value types that expedite and optimize the development process and provide access to system functionality.&lt;br /&gt;The .Net Framework class library (FCL) organized in a hierarchical tree structure and it is divided into &lt;a href="http://vb.net-informations.com/framework/namespaces.htm"&gt;Namespaces&lt;/a&gt;. Namespaces is a logical grouping of types for the purpose of identification. Framework class library (FCL) provides the consistent base types that are used across all .NET enabled languages. The Classes are accessed by namespaces, which reside within Assemblies. The System Namespace is the root for types in the .NET Framework. The .Net Framework class library (FCL) classes are managed classes that provide access to System Services . The .Net Framework class library (FCL) classes are object oriented and easy to use in program developments. Moreover, third-party components can integrate with the classes in the .NET Framework.&lt;br /&gt;Common Language Specification&lt;br /&gt;Common Language Specification (CLS) is a set of basic language features that .Net Languages needed to develop Applications and Services, which are compatible with the &lt;a href="http://vb.net-informations.com/framework/what_is_net_framework.htm"&gt;.Net Framework&lt;/a&gt;. When there is a situation to communicate Objects written in different .Net Complaint languages, those objects must expose the features that are common to all the languages. &lt;a href="http://vb.net-informations.com/framework/common_language_specification.htm"&gt;Common Language Specification&lt;/a&gt; (CLS) ensures complete interoperability among applications, regardless of the language used to create the application.&lt;br /&gt;Common Language Specification (CLS) defines a subset of &lt;a href="http://vb.net-informations.com/framework/common_type_system.htm"&gt;Common Type System&lt;/a&gt; (CTS). Common Type System (CTS) describes a set of types that can use different .Net languages have in common, which ensure that objects written in different languages can interact with each other. Most of the members defined by types in the .NET &lt;a href="http://vb.net-informations.com/framework/framework_class_library.htm"&gt;Framework Class Library&lt;/a&gt; (FCL) are Common Language Specification (CLS) compliant Types. Moreover Common Language Specification (CLS) standardized by ECMA.&lt;br /&gt;Common Type System&lt;br /&gt;Common Type System (CTS) describes a set of types that can be used in different .Net languages in common . That is , the Common Type System (CTS) ensure that objects written in different .Net languages can interact with each other. For Communicating between programs written in any .NET complaint language, the types have to be compatible on the basic level .&lt;br /&gt;These types can be Value Types or Reference Types . The Value Types are passed by values and stored in the stack. The Reference Types are passed by references and stored in the heap. Common Type System (CTS) provides base set of &lt;a href="http://vb.net-informations.com/language/vb.net_data_types.htm"&gt;Data Types&lt;/a&gt; which is responsible for cross language integration. The &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) can load and execute the source code written in any .Net language, only if the type is described in the Common Type System (CTS) .Most of the members defined by types in the .NET &lt;a href="http://vb.net-informations.com/framework/framework_class_library.htm"&gt;Framework Class Library&lt;/a&gt; (FCL) are &lt;a href="http://vb.net-informations.com/framework/common_language_specification.htm"&gt;Common Language Specification&lt;/a&gt; (CLS) compliant Types.&lt;br /&gt;Microsoft Intermediate Language&lt;br /&gt;MSIL stands for Microsoft Intermediate Language. We can call it as Intermediate Language (IL) or Common Intermediate Language (CIL). During the compile time , the compiler convert the source code into Microsoft Intermediate Language (MSIL) .Microsoft Intermediate Language (MSIL) is a CPU-independent set of instructions that can be efficiently converted to the native code. During the runtime the &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR)'s &lt;a href="http://vb.net-informations.com/framework/just_in_time_compiler.htm"&gt;Just In Time&lt;/a&gt; (JIT) compiler converts the Microsoft Intermediate Language (MSIL) code into native code to the Operating System.&lt;br /&gt;When a compiler produces Microsoft Intermediate Language (MSIL), it also produces &lt;a href="http://vb.net-informations.com/framework/metadata.htm"&gt;Metadata&lt;/a&gt;. The Microsoft Intermediate Language (MSIL) and Metadata are contained in a portable executable (PE) file . Microsoft Intermediate Language (MSIL) includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations&lt;br /&gt;Just In Time Compiler&lt;br /&gt;The .Net languages , which is conforms to the &lt;a href="http://vb.net-informations.com/framework/common_language_specification.htm"&gt;Common Language Specification&lt;/a&gt; (CLS), uses its corresponding runtime to run the application on different Operating Systems . During the code execution time, the &lt;a href="http://vb.net-informations.com/framework/managed_code.htm"&gt;Managed Code&lt;/a&gt; compiled only when it is needed, that is it converts the appropriate instructions to the native code for execution just before when each function is called. This process is called Just In Time (JIT) compilation, also known as Dynamic Translation . With the help of Just In Time Compiler (JIT) the &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) doing these tasks.&lt;br /&gt;The Common Language Runtime (CLR) provides various Just In Time compilers (JIT) and each works on a different architecture depending on Operating System. That is why the same &lt;a href="http://vb.net-informations.com/framework/microsoft_intermediate_language.htm"&gt;Microsoft Intermediate Language&lt;/a&gt; (MSIL) can be executed on different Operating Systems without rewrite the source code. Just In Time (JIT) compilation preserves memory and save time during application initialization. Just In Time (JIT) compilation is used to run at high speed, after an initial phase of slow interpretation. Just In Time Compiler (JIT) code generally offers far better performance than interpreters.&lt;br /&gt;Managed Code&lt;br /&gt;Managed Code in Microsoft &lt;a href="http://vb.net-informations.com/framework/what_is_net_framework.htm"&gt;.Net Framework&lt;/a&gt;, is the code that has executed by the &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) environment. On the other hand Unmanaged Code is directly executed by the computer's CPU. Data types, error-handling mechanisms, creation and destruction rules, and design guidelines vary between managed and unmanaged object models.&lt;br /&gt;The benefits of Managed Code include programmers convenience and enhanced security . Managed code is designed to be more reliable and robust than unmanaged code , examples are &lt;a href="http://vb.net-informations.com/framework/garbage_collection.htm"&gt;Garbage Collection&lt;/a&gt; , Type Safety etc. The Managed Code running in a Common Language Runtime (CLR) cannot be accessed outside the runtime environment as well as cannot call directly from outside the runtime environment. This makes the programs more isolated and at the same time computers are more secure . Unmanaged Code can bypass the .NET Framework and make direct calls to the Operating System. Calling unmanaged code presents a major security risk.&lt;br /&gt;.Net Metadata&lt;br /&gt;Metadata in .Net is binary information which describes the characteristics of a resource . This information include Description of the &lt;a href="http://vb.net-informations.com/framework/assembly.htm"&gt;Assembly&lt;/a&gt; , &lt;a href="http://vb.net-informations.com/language/vb.net_data_types.htm"&gt;Data Types&lt;/a&gt; and members with their declarations and implementations, references to other types and members , Security permissions etc. A module's metadata contains everything that needed to interact with another module.&lt;br /&gt;During the compile time Metadata created with &lt;a href="http://vb.net-informations.com/framework/microsoft_intermediate_language.htm"&gt;Microsoft Intermediate Language&lt;/a&gt; (MSIL) and stored in a file called a &lt;a href="http://vb.net-informations.com/framework/assembly_manifest.htm"&gt;Manifest&lt;/a&gt; . Both Metadata and Microsoft Intermediate Language (MSIL) together wrapped in a Portable Executable (PE) file. During the runtime of a program &lt;a href="http://vb.net-informations.com/framework/just_in_time_compiler.htm"&gt;Just In Time&lt;/a&gt; (JIT) compiler of the &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) uses the Metadata and converts Microsoft Intermediate Language (MSIL) into native code. When code is executed, the runtime loads metadata into memory and references it to discover information about your code's classes, members, inheritance, and so on. Moreover Metadata eliminating the need for Interface Definition Language (IDL) files, header files, or any external method of component reference.&lt;br /&gt;.Net Assembly&lt;br /&gt;Microsoft .Net Assembly is a logical unit of code, it contains code that the &lt;a href="http://vb.net-informations.com/framework/common_language_runtime.htm"&gt;Common Language Runtime&lt;/a&gt; (CLR) executes. Assembly is really a collection of types and resource information that are built to work together and form a logical unit of functionality. During the compile time &lt;a href="http://vb.net-informations.com/framework/metadata.htm"&gt;Metadata&lt;/a&gt; is created, with &lt;a href="http://vb.net-informations.com/framework/microsoft_intermediate_language.htm"&gt;Microsoft Intermediate Language&lt;/a&gt; (MSIL), and stored in a file called a &lt;a href="http://vb.net-informations.com/framework/assembly_manifest.htm"&gt;Manifest&lt;/a&gt; . Both Metadata and Microsoft Intermediate Language (MSIL) together wrapped in a Portable Executable (PE) file. Manifest contains information about itself. This information is called Assembly Manifest, it contains information about the members, types, references and all the other data that the runtime needs for execution.&lt;br /&gt;Every Assembly you create contains one or more program files and a Manifest. There are two types program files : Process Assemblies (EXE) and Library Assemblies (DLL). Each Assembly can have only one entry point (that is, DllMain, WinMain, or Main). We can create two types of Assembly, private Assembly and shared Assembly . A private Assembly is used only by a single application, and usually it is stored in that application's install directory. A shared Assembly is one that can be referenced by more than one application. If multiple applications need to access an Assembly, we should add the Assembly to the Global Assembly Cache (GAC).&lt;br /&gt;.Net Assembly Manifest&lt;br /&gt;An &lt;a href="http://vb.net-informations.com/framework/assembly.htm"&gt;Assembly&lt;/a&gt; Manifest is a file that containing &lt;a href="http://vb.net-informations.com/framework/metadata.htm"&gt;Metadata&lt;/a&gt; about .NET Assemblies. Assembly Manifest contains a collection of data that describes how the elements in the assembly relate to each other. It describes the relationship and dependencies of the components in the Assembly, versioning information, scope information and the security permissions required by the Assembly.&lt;br /&gt;The Assembly Manifest can be stored in Portable Executable (PE) file with &lt;a href="http://vb.net-informations.com/framework/microsoft_intermediate_language.htm"&gt;Microsoft Intermediate Language&lt;/a&gt; (MSIL) code. You can add or change some information in the Assembly Manifest by using assembly attributes in your code. The Assembly Manifest can be stored in either a PE file (an .exe or .dll) with &lt;a href="http://vb.net-informations.com/framework/microsoft_intermediate_language.htm"&gt;Microsoft Intermediate Language&lt;/a&gt; (MSIL) code or in a standalone PE file that contains only assembly manifest information. Using ILDasm, you can view the manifest information for any managed DLL.&lt;br /&gt;.Net Namespaces&lt;br /&gt;Namespaces are the way to organize .NET &lt;a href="http://vb.net-informations.com/framework/framework_class_library.htm"&gt;Framework Class Library&lt;/a&gt; into a logical grouping according to their functionality, usability as well as category they should belong to, or we can say &lt;a href="http://vb.net-informations.com/framework/namespaces.htm"&gt;Namespaces&lt;/a&gt; are logical grouping of types for the purpose of identification.&lt;br /&gt;The &lt;a href="http://vb.net-informations.com/framework/what_is_net_framework.htm"&gt;.NET Framework&lt;/a&gt; Class Library (FCL ) is a large collection of thousands of Classes. These Classes are organized in a hierarchical tree. The System Namespaces is the root for types in the .NET Framework. We can uniquely identify any Class in the .NET Framework Class Library (FCL ) by using the full Namespaces of the class .In .Net languages every program is created with a default Namespaces . Programmers can also create their own Namespaces in .Net languages.&lt;br /&gt;Garbage Collection&lt;br /&gt;The &lt;a href="http://vb.net-informations.com/framework/what_is_net_framework.htm"&gt;.Net Framework&lt;/a&gt; provides a new mechanism for releasing unreferenced objects from the memory (that is we no longer needed that objects in the program) ,this process is called Garbage Collection (GC). When a program creates an Object, the Object takes up the memory. Later when the program has no more references to that Object, the Object's memory becomes unreachable, but it is not immediately freed. The Garbage Collection checks to see if there are any Objects in the heap that are no longer being used by the application. If such Objects exist, then the memory used by these Objects can be reclaimed. So these unreferenced Objects should be removed from memory , then the other new Objects you create can find a place in the Heap.&lt;br /&gt;The reclaimed Objects have to be Finalized later. Finalization allows a resource to clean up after itself when it is being collected. This releasing of unreferenced Objects is happening automatically in .Net languages by the Garbage Collector (GC). The programming languages like C++, programmers are responsible for allocating memory for Objects they created in the application and reclaiming the memory when that Object is no longer needed for the program. In .Net languages there is a facility that we can call Garbage Collector (GC) explicitly in the program by calling System.GC.Collect.&lt;br /&gt;Threads&lt;br /&gt;Thread in computer science means a sequence of execution instructions that can run independently , that is a single flow of execution in a process. Thread is like a process, at least one thread exists within each process. Single Thread (normal programs) in computer science means that only one task can execute and at the same time the other tasks have to wait for the completion of the current task like in a queue. Single thread resulted in systems idle time and application performance.&lt;br /&gt;Multithreading allows multiple process to execute concurrently within a single program .That is more than one task in a program can execute at the same time and each thread run independently of its own. If multiple threads can exist within a process, typically share the state information of a process, and share memory and other resources directly. Each thread maintains exception handlers, a scheduling priority, and a set of structures the system uses to save the thread context until it is scheduled.&lt;br /&gt;In multiple threaded programming we can use system's idle time, so it leads improved application performance . Also we can set priority in each Threads . Threads with higher priority are executed in preference to threads with lower priority. It is recommended that you use as few threads as possible, thereby minimizing the use of Operating System resources . Check the following links to see how Multi Threaded applications works in VB.NET .&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-7221240927685848718?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/7221240927685848718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/introduction-to-net-framework.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7221240927685848718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/7221240927685848718'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/introduction-to-net-framework.html' title='Introduction to .Net Framework'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-5631770095145465440</id><published>2009-01-30T04:08:00.000-08:00</published><updated>2009-01-30T04:09:27.884-08:00</updated><title type='text'>Object-Oriented Programming Concepts and .NET</title><content type='html'>Classes, Objects, and Structures in .NET&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Object-Oriented Programming (OOP) is a software development paradigm that suggests developers to split a program in building blocks known as objects. The OOP paradigm allows developers to define the object’s data, functions, and its relationship with other objects.&lt;br /&gt;&lt;br /&gt;Microsoft created the .NET Framework using OOP, and knowing this concepts has helped me to understand the .NET Framework and to design and develop better software components. The purpose of this article is to describe the basic OOP concepts using real world scenarios and to provide some code samples that demonstrate how to work with OOP and .NET.&lt;br /&gt;Class&lt;br /&gt;&lt;br /&gt;The most common definition states that a class is a template for an object. Suppose that someone builds a paper pattern for a shirt. All the shirts done with the same paper pattern will be identical (same design, size, etc.). In this sample, the paper pattern is the class and the shirt is the object. To build the same exact shirt over and over, you need the paper pattern as a template.  Another great example are house plans and blueprints. The plans and blueprints define the number of rooms, the size of the kitchen, the number of floors, and more. In this real world sample, the house plans and blueprints are the class and the house is the object. In OOP you program a class as a template for a specific object or groups ob objects that will always have the same features.&lt;br /&gt;Class members&lt;br /&gt;&lt;br /&gt;A class has different members, and developers in Microsoft suggest to program them in the following order:&lt;br /&gt;Namespace: The namespace is a keyword that defines a distinctive name or last name for the class. A namespace categorizes and organizes the library (assembly) where the class belongs and avoids collisions with classes that share the same name.&lt;br /&gt;Class declaration: Line of code where the class name and type are defined.&lt;br /&gt;Fields: Set of variables declared in a class block.&lt;br /&gt;Constants: Set of constants declared in a class block.&lt;br /&gt;Constructors: A method or group of methods that contains code to initialize the class.&lt;br /&gt;Properties: The set of descriptive data of an object.&lt;br /&gt;Events: Program responses that get fired after a user or application action.&lt;br /&gt;Methods: Set of functions of the class.&lt;br /&gt;Destructor: A method that is called when the class is destroyed. In managed code, the Garbage Collector is in charge of destroying objects; however, in some cases developers need to take extra actions when objects are being released, such as freeing handles or deallocating unmanaged objects. In .NET, there is no concept of deterministic destructors. The Garbage Collector will call the Finalize() method at a non-deterministic time while reclaiming memory for the application.&lt;br /&gt;Access keywords&lt;br /&gt;&lt;br /&gt;Access keywords define the access to class members from the same class and from other classes. The most common access keywords are:&lt;br /&gt;Public: Allows access to the class member from any other class.&lt;br /&gt;Private: Allows access to the class member only in the same class.&lt;br /&gt;Protected: Allows access to the class member only within the same class and from inherited classes.&lt;br /&gt;Internal: Allows access to the class member only in the same assembly.&lt;br /&gt;Protected internal: Allows access to the class member only within the same class, from inherited classes, and other classes in the same assembly.&lt;br /&gt;Static: Indicates that the member can be called without first instantiating the class.&lt;br /&gt;&lt;br /&gt;The following sample code illustrates a sample class in C#:&lt;br /&gt;/// C#&lt;br /&gt;///Imported namespaces&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;/// Namespace: Consider using CompanyName.Product.ComponentType&lt;br /&gt;namespace DotNetTreats.OOSE.OOP_CSharp {&lt;br /&gt;   &lt;br /&gt;    ///Class declaration&lt;br /&gt;    public class employee {&lt;br /&gt;   &lt;br /&gt;        ///Fields&lt;br /&gt;        private string _name;&lt;br /&gt;        private int _salary;&lt;br /&gt;       &lt;br /&gt;        ///Constants&lt;br /&gt;        private const int anualBonus = 1000;&lt;br /&gt;       &lt;br /&gt;        ///Constructor&lt;br /&gt;        public employee(){&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        ///Properties&lt;br /&gt;        public string Name {&lt;br /&gt;            get {&lt;br /&gt;                return _name;&lt;br /&gt;            }&lt;br /&gt;            set {&lt;br /&gt;                _name = value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        public int Salary {&lt;br /&gt;            get {&lt;br /&gt;                return _salary;&lt;br /&gt;            }&lt;br /&gt;            set {&lt;br /&gt;                _salary = value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// Event handlers&lt;br /&gt;        public event EventHandler OnPromotion {&lt;br /&gt;            add {&lt;br /&gt;            }&lt;br /&gt;            remove {&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// Methods&lt;br /&gt;        public void DuplicateSalary() {&lt;br /&gt;            _salary = _salary*2;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Listing 1. Sample class implementation in C#&lt;br /&gt;&lt;br /&gt;The following sample code illustrates a sample class in VB.NET:&lt;br /&gt;' VB.NET &lt;br /&gt;'Imported namespaces&lt;br /&gt;Imports System&lt;br /&gt;&lt;br /&gt;' Namespace: Consider using CompanyName.Product.ComponentType&lt;br /&gt;Namespace DotNetTreats.OOSE.OOP_VBNET&lt;br /&gt;   &lt;br /&gt;'Class declaration&lt;br /&gt;    Public Class employee&lt;br /&gt;       &lt;br /&gt;        'Fields&lt;br /&gt;        Private _name As String&lt;br /&gt;        Private _salary As Integer&lt;br /&gt;       &lt;br /&gt;        'Constants&lt;br /&gt;        Private Const anualBonus As Integer = 1000&lt;br /&gt;&lt;br /&gt;        'Constructors       &lt;br /&gt;        Public Sub New()&lt;br /&gt;            MyBase.New&lt;br /&gt;        End Sub&lt;br /&gt;       &lt;br /&gt;        'Properties&lt;br /&gt;        Public Property Name As String&lt;br /&gt;            Get&lt;br /&gt;                Return _name&lt;br /&gt;            End Get&lt;br /&gt;            Set&lt;br /&gt;                _name = value&lt;br /&gt;            End Set&lt;br /&gt;        End Property&lt;br /&gt;       &lt;br /&gt;        Public Property Salary As Integer&lt;br /&gt;            Get&lt;br /&gt;                Return _salary&lt;br /&gt;            End Get&lt;br /&gt;            Set&lt;br /&gt;                _salary = value&lt;br /&gt;            End Set&lt;br /&gt;        End Property&lt;br /&gt;       &lt;br /&gt;        ' Event handlers&lt;br /&gt;        Public Event OnPromotion As EventHandler&lt;br /&gt;       &lt;br /&gt;        'Methods&lt;br /&gt;        Public Sub DuplicateSalary()&lt;br /&gt;            _salary = (_salary * 2)&lt;br /&gt;        End Sub&lt;br /&gt;   &lt;br /&gt;    End Class&lt;br /&gt;&lt;br /&gt;End Namespace&lt;br /&gt;&lt;br /&gt;Listing 2. Sample class implementation in VB.NET&lt;br /&gt;&lt;br /&gt;Object&lt;br /&gt;&lt;br /&gt;Objects are the building blocks of OOP and are commonly defined as  variables or data structures that encapsulate behavior and data in a programmed unit. Objects are items that can be individually created, manipulated, and represent real world things in an abstract way.&lt;br /&gt;Object composition&lt;br /&gt;&lt;br /&gt;Every object is composed by:&lt;br /&gt;Object identity: Means that every object is unique and can be differentiated from other objects.  Each time and object is created (instantiated) the object identity is defined.&lt;br /&gt;Object behavior: What the object can do. In OOP, methods work as functions that define the set of actions that the object can do.&lt;br /&gt;Object state: The data stored within the object at any given moment. In OOP, fields, constants, and properties define the state of an object.&lt;br /&gt;Structures&lt;br /&gt;&lt;br /&gt;Not everything in the real world should be represented as a class. Structures are suitable to represent lightweight objects. Structures can have methods and properties and are useful for defining types that act as user-defined primitives, but contain arbitrary composite fields. The .NET Framework defines some structures such as System.Drawing.Rectangle, System.Drawing.Point, and System.Drawing.Color.&lt;br /&gt;&lt;br /&gt;The following code sample represents a structures in C#:&lt;br /&gt;/// C#&lt;br /&gt;struct Point {&lt;br /&gt;    private int _x;&lt;br /&gt;    private int _y;&lt;br /&gt;&lt;br /&gt;    Point(int x, int y){&lt;br /&gt;        this._x = x;&lt;br /&gt;        this._y = y;   &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public int X {&lt;br /&gt;        get {&lt;br /&gt;            return _x;&lt;br /&gt;        }&lt;br /&gt;        set {&lt;br /&gt;            _x = value;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public int Y {&lt;br /&gt;        get {&lt;br /&gt;            return _y;&lt;br /&gt;        }&lt;br /&gt;        set {&lt;br /&gt;            _y = value;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Listing 3. Sample structure implementation in C#&lt;br /&gt;&lt;br /&gt;The following code sample represents a structure in VB.NET:&lt;br /&gt;' VB.NET &lt;br /&gt;Structure Point&lt;br /&gt;    Private _x As Integer&lt;br /&gt;    Private _y As Integer&lt;br /&gt;   &lt;br /&gt;    Sub New(ByVal x As Integer, ByVal y As Integer)&lt;br /&gt;        MyBase.New&lt;br /&gt;        Me._x = x&lt;br /&gt;        Me._y = y&lt;br /&gt;    End Sub&lt;br /&gt;   &lt;br /&gt;    Public Property X As Integer&lt;br /&gt;        Get&lt;br /&gt;            Return _x&lt;br /&gt;        End Get&lt;br /&gt;        Set&lt;br /&gt;            _x = value&lt;br /&gt;        End Set&lt;br /&gt;    End Property&lt;br /&gt;   &lt;br /&gt;    Public Property Y As Integer&lt;br /&gt;        Get&lt;br /&gt;            Return _y&lt;br /&gt;        End Get&lt;br /&gt;        Set&lt;br /&gt;            _y = value&lt;br /&gt;        End Set&lt;br /&gt;    End Property&lt;br /&gt;End Structure&lt;br /&gt;&lt;br /&gt;Listing 4. Sample structure implementation in VB.NET&lt;br /&gt;&lt;br /&gt;Conclusion&lt;br /&gt;&lt;br /&gt;OOP is full of abstract concepts, and the best approach to understand them is practical and not only theoretical. I learned more OOP after making some designs and after implementing some components. The concepts presented in this article might clarify the meaning, but I strongly recommend to go and have fun playing around with OOP. In this article, I examined the concept of classes, objects, and structs. The second part will examine the concepts of inheritance, abstraction, and polimorphism.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-5631770095145465440?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/5631770095145465440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/object-oriented-programming-concepts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/5631770095145465440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/5631770095145465440'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/object-oriented-programming-concepts.html' title='Object-Oriented Programming Concepts and .NET'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-9187348145452544372</id><published>2009-01-29T23:57:00.000-08:00</published><updated>2009-01-29T23:58:15.406-08:00</updated><title type='text'>How to make connection with Access Database that has database password</title><content type='html'>&lt;pre class="csharpcode"&gt;Summary:This Program will connect to a Microsoft Access database with database password with ADO.net.SolutionJet OLEDB:Database Password attribute &lt;span class="kwrd"&gt;in&lt;/span&gt; the connection &lt;span class="kwrd"&gt;string&lt;/span&gt; &lt;span class="kwrd"&gt;is&lt;/span&gt; use to specify the password.&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Configuration;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data.OleDb;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; connectButton_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, System.EventArgs e){    StringBuilder result = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder( );&lt;br /&gt;    &lt;span class="rem"&gt;// Build the connections string incorporating the password.&lt;/span&gt;    String connectionString =        ConfigurationSettings.AppSettings[&lt;span class="str"&gt;"MsAccess_Secure_ConnectString"&lt;/span&gt;]+        &lt;span class="str"&gt;"Jet OLEDB:Database Password="&lt;/span&gt; + passwordTextBox.Text + &lt;span class="str"&gt;";"&lt;/span&gt;;&lt;br /&gt;    result.Append(&lt;span class="str"&gt;"ConnectionString: "&lt;/span&gt; + Environment.NewLine +        connectionString + Environment.NewLine + Environment.NewLine);&lt;br /&gt;    OleDbConnection conn = &lt;span class="kwrd"&gt;new&lt;/span&gt; OleDbConnection(connectionString);    &lt;span class="kwrd"&gt;try&lt;/span&gt;    {        conn.Open( );&lt;br /&gt;        &lt;span class="rem"&gt;// Retrieve some database information.&lt;/span&gt;        result.Append(            &lt;span class="str"&gt;"Connection State: "&lt;/span&gt; + conn.State + Environment.NewLine +            &lt;span class="str"&gt;"OLE DB Provider: "&lt;/span&gt; + conn.Provider +            Environment.NewLine +            &lt;span class="str"&gt;"Server Version: "&lt;/span&gt; + conn.ServerVersion +            Environment.NewLine);&lt;br /&gt;        conn.Close( );        result.Append(&lt;span class="str"&gt;"Connection State: "&lt;/span&gt; + conn.State);    }    &lt;span class="kwrd"&gt;catch&lt;/span&gt;(System.Data.OleDb.OleDbException ex)    {        conn.Close( );        result.Append(&lt;span class="str"&gt;"ERROR: "&lt;/span&gt; + ex.Message);    }&lt;br /&gt;    resultTextBox.Text = result.ToString( );}DiscussionA Microsoft Access database password requires that users enter a password to obtain access to the database and database objects. This &lt;span class="kwrd"&gt;is&lt;/span&gt; also known &lt;span class="kwrd"&gt;as&lt;/span&gt; share-level security. A password does not allow groups or users to have distinct levels of access or permissions. Anyone with the password has unrestricted access to the database.The Set Database command from the Tools &amp;gt; Security menu &lt;span class="kwrd"&gt;is&lt;/span&gt; used to set up a database password.The OLE DB provider &lt;span class="kwrd"&gt;for&lt;/span&gt; Microsoft Jet has several provider-specific connection &lt;span class="kwrd"&gt;string&lt;/span&gt; attributes &lt;span class="kwrd"&gt;in&lt;/span&gt; addition to those defined by ADO.NET. To open a database secured by a Microsoft Access database password, use the Jet OLEDB:Database Password attribute &lt;span class="kwrd"&gt;in&lt;/span&gt; the connection &lt;span class="kwrd"&gt;string&lt;/span&gt; to specify the password. This corresponds to the OLE DB property DBPROP_JETOLEDB_DATABASEPASSWORD.&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-9187348145452544372?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/9187348145452544372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/how-to-make-connection-with-access_29.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/9187348145452544372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/9187348145452544372'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/how-to-make-connection-with-access_29.html' title='How to make connection with Access Database that has database password'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1117992870719122389.post-3937855434386709092</id><published>2009-01-29T23:50:00.000-08:00</published><updated>2009-01-29T23:52:03.503-08:00</updated><title type='text'>Common Language Runtime in .Net</title><content type='html'>&lt;a name="dotnetfrmess3-CHP-2-FIG-4"&gt;&lt;/a&gt;Summary:&lt;br /&gt;This article will give brief description about Common Language Runtime and its components.&lt;br /&gt;Common Language Runtime (CLR)&lt;br /&gt;The Common Language Runtime (CLR) is an Execution Environment . It works as a layer between Operating Systems and the applications written in .Net languages that conforms to the &lt;a href="http://vb.net-informations.com/framework/common_language_specification.htm"&gt;Common Language Specification&lt;/a&gt; (CLS). The main function of Common Language Runtime (CLR) is to convert the &lt;a href="http://vb.net-informations.com/framework/managed_code.htm"&gt;Managed Code&lt;/a&gt; into native code and then execute the Program. The Managed Code compiled only when it needed, that is it converts the appropriate instructions when each function is called. The Common Language Runtime (CLR) 's &lt;a href="http://vb.net-informations.com/framework/just_in_time_compiler.htm"&gt;Just In Time&lt;/a&gt; (JIT) compilation converts Intermediate Language (MSIL) to native code on demand at application run time.&lt;br /&gt;During the execution of the program ,the Common Language Runtime (CLR) manages memory, &lt;a href="http://vb.net-informations.com/framework/threads.htm"&gt;Thread&lt;/a&gt; execution, &lt;a href="http://vb.net-informations.com/framework/garbage_collection.htm"&gt;Garbage Collection&lt;/a&gt; (GC) , &lt;a href="http://vb.net-informations.com/language/vb.net_exceptions.htm"&gt;Exception&lt;/a&gt; Handling, &lt;a href="http://vb.net-informations.com/framework/common_type_system.htm"&gt;Common Type System&lt;/a&gt; (CTS), code safety verifications, and other system services. The CLR ( Common Language Runtime ) defines the Common Type System (CTS), which is a standard type system used by all .Net languages. That means all .NET programming languages uses the same representation for common &lt;a href="http://vb.net-informations.com/language/vb.net_data_types.htm"&gt;Data Types&lt;/a&gt; , so Common Language Runtime (CLR) is a language-independent runtime environment . The Common Language Runtime (CLR) environment is also referred to as a managed environment, because during the execution of a program it also controls the interaction with the Operating System.&lt;br /&gt;&lt;br /&gt; Major CLR components: the Virtual Execution System (VES)&lt;br /&gt;The major components of the CLR include the class loader, verifier, JIT compilers, and other execution support, such as code management, security management, garbage collection, exception management, debug management, marshaling management, thread management, and so on..NET PE files lay on top of the CLR and execute within the CLR's&lt;a name="dotnetfrmess3-CHP-2-ITERM-1336"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1335"&gt;&lt;/a&gt; Virtual Execution System (VES), which hosts the major components of the runtime. Your .NET PE files will have to go through the class loader, the type verifier, the JIT compilers, and other execution support components before they will execute.&lt;br /&gt;&lt;a name="dotnetfrmess3-CHP-2-SECT-7.1"&gt;&lt;/a&gt;Class Loader&lt;br /&gt;When &lt;a name="dotnetfrmess3-CHP-2-ITERM-1338"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1337"&gt;&lt;/a&gt;you run a standard Windows application, the OS loader loads it before it can execute. At the time of this writing, the default loaders in the existing Windows operating systems, such as &lt;a name="dotnetfrmess3-CHP-2-ITERM-1341"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1340"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1339"&gt;&lt;/a&gt;Windows 98, Windows Me, Windows 2000, and so forth, recognize only the standard Windows PE files. As a result, Microsoft has provided an updated OS loader for each of these operating systems that support the .NET runtime. The updated OS loaders know the .NET PE file format and can handle the file appropriately.&lt;br /&gt;When you run a .NET application on one of these systems that have an updated OS loader, the OS loader recognizes the .NET application and thus passes control to the CLR. The CLR then finds the entry point, which is typically Main( ), and executes it to jump-start the application. But before Main( ) can execute, the class loader must find the class that exposes Main( ) and load the class. In addition, when Main( ) instantiates an object of a specific class, the class loader also kicks in. In short, the class loader performs its magic the first time a type is referenced.&lt;br /&gt;The class loader loads .NET classes into memory and prepares them for execution. Before it can successfully do this, it must locate the target class. To find the target class, the class loader looks in several different places, including the application&lt;a name="dotnetfrmess3-CHP-2-ITERM-1342"&gt;&lt;/a&gt; &lt;a name="dotnetfrmess3-CHP-2-ITERM-1343"&gt;&lt;/a&gt;configuration file (.config) in the current directory, the GAC, and the metadata that is part of the PE file, specifically the manifest. The information that is provided by one or more of these items is crucial to locating the correct target class. Recall that a class can be scoped to a particular namespace, a namespace can be scoped to a particular assembly, and an assembly can be scoped to a specific version. Given this, two classes, both named Car, are treated as different types even if the version information of their assemblies are the same.&lt;br /&gt;Once the class loader has found and loaded the target class, it caches the type information for the class so that it doesn't have to load the class again for the duration of this process. By caching this information, it will later determine how much memory is needed to allocate for the newly created instance of this class. Once the target class is loaded, the class loader injects a small stub, like a function prolog, into every single method of the loaded class. This stub is used for two purposes: to denote the status of JIT compilation and to transition between managed and unmanaged code. At this point, if the loaded class references other classes, the class loader will also try to load the referenced types. However, if the referenced types have already been loaded, the class loader has to do nothing. Finally, the class loader uses the appropriate metadata to initialize the static variables and instantiate an object of the loaded class for you.&lt;br /&gt;&lt;a name="dotnetfrmess3-CHP-2-SECT-7.2"&gt;&lt;/a&gt;Verifier&lt;br /&gt;Scripting &lt;a name="dotnetfrmess3-CHP-2-ITERM-1345"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1344"&gt;&lt;/a&gt;and interpreted languages are very lenient on type usages, allowing you to write code without explicit variable declarations. This flexibility can introduce code that is extremely error-prone and hard to maintain, and that is often a culprit for mysterious program crashes. Unlike scripting and interpreted languages, compiled languages require types to be explicitly defined prior to their use, permitting the compiler to ensure that types are used correctly and the code will execute peacefully at runtime.&lt;br /&gt;The key here is type safety, and it is a fundamental concept for&lt;a name="dotnetfrmess3-CHP-2-ITERM-1346"&gt;&lt;/a&gt; code verification in .NET. Within the VES, the verifier is the component that executes at runtime to verify that the code is type safe. Note that this type verification is done at runtime and that this is a fundamental difference between .NET and other environments. By verifying type safety at runtime, the CLR can prevent the execution of code that is not type safe and ensure that the code is used as intended. In short, type safety means more reliability.&lt;br /&gt;Let's talk about where the verifier fits within the CLR. After the class loader has loaded a class and before a piece of IL code can execute, the verifier kicks in for code that must be verified. The verifier is responsible for verifying that:&lt;br /&gt;The metadata is well formed, meaning the metadata must be valid.&lt;br /&gt;The IL code is type safe, meaning type signatures are used correctly.&lt;br /&gt;Both of these criteria must be met before the code can be executed because JIT compilation will take place only when code and metadata have been successfully verified. In addition to checking for type safety, the verifier also performs rudimentary control-flow analysis of the code to ensure that the code is using types correctly. You should note that since the verifier is a part of the JIT compilers, it kicks in only when a method is being invoked, not when a class or assembly is loaded. You should also note that verification is an optional step because trusted code will never be verified but will be immediately directed to the JIT compiler for compilation.&lt;br /&gt;&lt;a name="dotnetfrmess3-CHP-2-SECT-7.3"&gt;&lt;/a&gt;JIT Compilers&lt;br /&gt;JIT &lt;a name="dotnetfrmess3-CHP-2-ITERM-1348"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1347"&gt;&lt;/a&gt;compilers play a major role in the .NET platform because all .NET PE files contain &lt;a name="dotnetfrmess3-CHP-2-ITERM-1349"&gt;&lt;/a&gt;IL and metadata, not native code. The JIT compilers convert IL to native code so that it can execute on the target operating system. For each method that has been successfully verified for type safety, a JIT compiler in the CLR will compile the method and convert it into native code.&lt;br /&gt;One advantage of a JIT compiler is that it can dynamically compile code that is optimized for the target machine. If you take the same .NET &lt;a name="dotnetfrmess3-CHP-2-ITERM-1350"&gt;&lt;/a&gt;PE file from a one-CPU machine to a two-CPU machine, the JIT compiler on the two-CPU machine knows about the second CPU and may be able to spit out the native code that takes advantage of the second CPU. Another obvious advantage is that you can take the same .NET PE file and run it on a totally different platform, whether it be Windows, Unix, or whatever, as long as that platform has a CLR.&lt;br /&gt;For optimization reasons, JIT compilation occurs only the first time a method is invoked. Recall that the class loader adds a stub to each method during class loading. At the first method invocation, the VES reads the information in this stub, which tells it that the code for the method has not been JIT-compiled. At this indication, the JIT compiler compiles the method and injects the address of the native method into this stub. During subsequent invocations to the same method, no JIT compilation is needed because each time the VES goes to read information in the stub, it sees the address of the native method. Because the JIT compiler only performs its magic the first time a method is invoked, the methods you don't need at runtime will never be JIT-compiled.&lt;br /&gt;The compiled, native code lies in memory until the process shuts down and until the garbage collector clears off all references and memory associated with the process. This means that the next time you execute the process or component, the JIT compiler will again perform its magic.&lt;br /&gt;If you want to avoid the cost of JIT compilation at runtime, you can use a special tool called ngen.exe, which compiles your IL during installation and setup time. Using ngen, you can JIT-compile the code once and cache it on the machine so that you can avoid JIT compilation at runtime (this process is referred to as pre-JITting). In the event that the PE file has been updated, you must &lt;a name="dotnetfrmess3-CHP-2-ITERM-1351"&gt;&lt;/a&gt;PreJIT the PE file again. Otherwise, the CLR can detect the update and dynamically command the appropriate JIT compiler to compile the assembly.&lt;br /&gt;&lt;a name="dotnetfrmess3-CHP-2-SECT-7.4"&gt;&lt;/a&gt;Execution Support and Management&lt;br /&gt;By &lt;a name="dotnetfrmess3-CHP-2-ITERM-1352"&gt;&lt;/a&gt;now, you should see that every component in the CLR that we've covered so far uses metadata and IL in some way to successfully carry out the services that it supports. In addition to the provided metadata and generated managed code, the JIT compiler must generate managed data that the code manager needs to locate and unwind stack frames. The&lt;a name="dotnetfrmess3-CHP-2-ITERM-1353"&gt;&lt;/a&gt; code manager uses managed data to control the execution of code, including performing stack walks that are required for exception handling, security checks, and garbage collection. Besides the code manager, the CLR also provides a number of important execution-support and management services. A detailed discussion of these services is beyond the scope of this book, so we will briefly enumerate a few of them here:&lt;br /&gt;By the way, you can write a custom JIT compiler or a custom code manager for the CLR because the CLR supports the plug-and-play of these components.&lt;br /&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1358"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1357"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1356"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1355"&gt;&lt;/a&gt;&lt;a name="dotnetfrmess3-CHP-2-ITERM-1354"&gt;Garbage collection &lt;/a&gt;&lt;br /&gt;Unlike C++, where you must delete all heap-based objects manually, the CLR supports automatic lifetime management for all .NET objects. The garbage collector can detect when your objects are no longer being referenced and perform garbage collection to reclaim the unused memory.&lt;br /&gt;Exception handling&lt;br /&gt;Prior to .NET, there was no consistent method for error or exception handling, causing lots of pain in error handling and reporting. In .NET, the CLR supports a standard exception-handling mechanism that works across all languages, allowing every program to use a common error-handling mechanism. The CLR exception-handling mechanism is integrated with Windows Structured Exception Handling (SEH).&lt;br /&gt;Security support&lt;br /&gt;The CLR performs various security checks at runtime to make sure that the code is safe to execute and that the code is not breaching any security requirements. In addition to supporting code access security, the security engine also supports declarative and imperative security checks. Declarative security requires no special security code, but you have to specify the security requirements through attributes or administrative configuration. Imperative security requires that you write the code in your method to specifically cause security checks.&lt;br /&gt;Debugging support&lt;br /&gt;The CLR provides rich support for debugging and profiling. There is an API that compiler vendors can use to develop a debugger. This API contains support for controlling program execution, breakpoints, exceptions, control flow, and so forth. There is also an API for tools to support the profiling of running programs.&lt;br /&gt;Interoperation support&lt;br /&gt;The CLR supports interoperation between the managed (CLR) and unmanaged (no CLR) worlds. The COM Interop facility serves as a bridge between COM and the CLR, allowing a COM object to use a .NET object, and vice versa. The Platform Invoke (P/Invoke) facility allows you to call Windows API functions.&lt;br /&gt;This is by no means an exhaustive list. The one thing that we want to reiterate is that like the class loader, verifier, JIT compiler, and just about everything else that deals with .NET, these execution-support and management facilities all use metadata, managed code, and managed data in some way to carry out their services.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1117992870719122389-3937855434386709092?l=kalitsikka.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalitsikka.blogspot.com/feeds/3937855434386709092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/common-language-runtime-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/3937855434386709092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1117992870719122389/posts/default/3937855434386709092'/><link rel='alternate' type='text/html' href='http://kalitsikka.blogspot.com/2009/01/common-language-runtime-in-net.html' title='Common Language Runtime in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry></feed>
