<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://jholjhapata.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Admin</id>
	<title>JholJhapata - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://jholjhapata.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Admin"/>
	<link rel="alternate" type="text/html" href="https://jholjhapata.com/wiki/Special:Contributions/Admin"/>
	<updated>2026-05-20T23:08:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://jholjhapata.com/index.php?title=SudokuSolver&amp;diff=151</id>
		<title>SudokuSolver</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=SudokuSolver&amp;diff=151"/>
		<updated>2025-06-01T08:13:52Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;Here’s a simple Sudoku Solver in C# using backtracking. It works on a standard 9x9 Sudoku grid.   SudokuSolver      using System;     using S...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here’s a simple Sudoku Solver in C# using backtracking. It works on a standard 9x9 Sudoku grid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:SudokuSolver.png|thumb|SudokuSolver]]&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.Threading;&lt;br /&gt;
    using System.Threading.Tasks;&lt;br /&gt;
    namespace sudoku_console&lt;br /&gt;
    {&lt;br /&gt;
        internal class Program&lt;br /&gt;
        {&lt;br /&gt;
            static int SIZE = 9;&lt;br /&gt;
            public static void Main()&lt;br /&gt;
            {&lt;br /&gt;
                int[,] board = {&lt;br /&gt;
                {5, 3, 0, 0, 7, 0, 0, 0, 0},&lt;br /&gt;
                {6, 0, 0, 1, 9, 5, 0, 0, 0},&lt;br /&gt;
                {0, 9, 8, 0, 0, 0, 0, 6, 0},&lt;br /&gt;
                {8, 0, 0, 0, 6, 0, 0, 0, 3},&lt;br /&gt;
                {4, 0, 0, 8, 0, 3, 0, 0, 1},&lt;br /&gt;
                {7, 0, 0, 0, 2, 0, 0, 0, 6},&lt;br /&gt;
                {0, 6, 0, 0, 0, 0, 2, 8, 0},&lt;br /&gt;
                {0, 0, 0, 4, 1, 9, 0, 0, 5},&lt;br /&gt;
                {0, 0, 0, 0, 8, 0, 0, 7, 9}&lt;br /&gt;
            };&lt;br /&gt;
                if (Solve(board))&lt;br /&gt;
                {&lt;br /&gt;
                    PrintBoard(board);&lt;br /&gt;
                    Console.ReadLine();&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;No solution exists.&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            static bool Solve(int[,] board, bool isTimer = false)&lt;br /&gt;
            {&lt;br /&gt;
                for (int row = 0; row &amp;lt; SIZE; row++)&lt;br /&gt;
                {&lt;br /&gt;
                    for (int col = 0; col &amp;lt; SIZE; col++)&lt;br /&gt;
                    {&lt;br /&gt;
                        if (board[row, col] == 0)&lt;br /&gt;
                        {&lt;br /&gt;
                            for (int num = 1; num &amp;lt;= 9; num++)&lt;br /&gt;
                            {&lt;br /&gt;
                                if (IsValid(board, row, col, num))&lt;br /&gt;
                                {&lt;br /&gt;
                                    board[row, col] = num;&lt;br /&gt;
                                    if (isTimer)&lt;br /&gt;
                                        Thread.Sleep(1000);&lt;br /&gt;
                                    if (Solve(board))&lt;br /&gt;
                                        return true;&lt;br /&gt;
                                    board[row, col] = 0; // backtrack&lt;br /&gt;
                                }&lt;br /&gt;
                            }&lt;br /&gt;
                            return false; // no valid number found&lt;br /&gt;
                        }&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
                return true; // board is solved&lt;br /&gt;
            }&lt;br /&gt;
            static bool IsValid(int[,] board, int row, int col, int num)&lt;br /&gt;
            {&lt;br /&gt;
                for (int x = 0; x &amp;lt; SIZE; x++)&lt;br /&gt;
                {&lt;br /&gt;
                    if (board[row, x] == num || board[row, x] == num)&lt;br /&gt;
                        return false;&lt;br /&gt;
                }&lt;br /&gt;
                for (int x = 0; x &amp;lt; SIZE; x++)&lt;br /&gt;
                {&lt;br /&gt;
                    if (board[x, col] == num || board[x, col] == num)&lt;br /&gt;
                        return false;&lt;br /&gt;
                }&lt;br /&gt;
                int startRow = row / 3 * 3;&lt;br /&gt;
                int startCol = col / 3 * 3;&lt;br /&gt;
                for (int i = 0; i &amp;lt; 3; i++)&lt;br /&gt;
                {&lt;br /&gt;
                    for (int j = 0; j &amp;lt; 3; j++)&lt;br /&gt;
                    {&lt;br /&gt;
                        if (board[startRow + i, startCol + j] == num)&lt;br /&gt;
                            return false;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
                return true;&lt;br /&gt;
            }&lt;br /&gt;
            static void PrintBoard(int[,] board)&lt;br /&gt;
            {&lt;br /&gt;
                for (int i = 0; i &amp;lt; SIZE; i++)&lt;br /&gt;
                {&lt;br /&gt;
                    for (int j = 0; j &amp;lt; SIZE; j++)&lt;br /&gt;
                    {&lt;br /&gt;
                        Console.Write(board[i, j] + &amp;quot; &amp;quot;);&lt;br /&gt;
                    }&lt;br /&gt;
                    Console.WriteLine();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=File:SudokuSolver.png&amp;diff=150</id>
		<title>File:SudokuSolver.png</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=File:SudokuSolver.png&amp;diff=150"/>
		<updated>2025-06-01T08:12:48Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;SudokuSolver&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=149</id>
		<title>State Management in ASP.NET</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=149"/>
		<updated>2022-08-03T12:21:58Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* OutProc */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in the past.&lt;br /&gt;
&lt;br /&gt;
Stateless means, whenever we visit a website, our browser communicates with the respective server depending on our requested functionality or the request. In this case HTTP/HTTPs doesn't remember what website or URL we visited, or in other words we can say it doesn't hold the state of a previous website that we visited before closing our browser, that is called stateless.&lt;br /&gt;
&lt;br /&gt;
So our browsers are stateless.&lt;br /&gt;
&lt;br /&gt;
== State Management Types ==&lt;br /&gt;
[[File:State Management Techniques.png|none|State Management Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Client-side | Techniques ==&lt;br /&gt;
=== View State ===&lt;br /&gt;
[[ASP.NET View State|View State]] is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.Please keep in mind though, that while cookies and sessions can be accessed from all your pages on your website, ViewState values are not carried between pages.&lt;br /&gt;
 &lt;br /&gt;
=== Hidden field ===&lt;br /&gt;
[[ASP.NET Hidden Field|Hidden Field]] is non visual control in ASP.NET where we can save the value. This is one of the types of client-side state management tools. It stores the value between the roundtrip. Anyone can see Hidden Field details by simply viewing the source of document.&lt;br /&gt;
=== Cookies ===&lt;br /&gt;
[[ASP.NET Cookies|Cookies]] is a small piece of information stored on the client machine. Its is used to store user preference information like Password, City, SessionId etc on client machines. We need to import namespace called Systen.Web before we use cookie(HttpCookie).&lt;br /&gt;
=== Control State ===&lt;br /&gt;
The '''control state''' is a way to save a control’s state information when the EnableViewState property is turned off. Unlike ViewState a developer can’t turn off control state. The control state can be implemented only in controls that you implement. ControlState is used to store small amounts of critical information. Heavy usage of ControlState can impact the performance of application because it involves '''serialization''' and '''deserialization''' for its functioning.&lt;br /&gt;
&lt;br /&gt;
There are two methods('''SaveControlState''' and '''LoadControlState''') which we have to implement in your custom control and on '''OnInit''' method of the control we need to add the call for the '''Page.RegisterRequiresControlState()''' method with the instance of the control to register.&lt;br /&gt;
&lt;br /&gt;
    public class ControlWebControl : Control&lt;br /&gt;
    {&lt;br /&gt;
        private string _strStateToSave;&lt;br /&gt;
        protected override void OnInit(EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
            Page.RegisterRequiresControlState(this);&lt;br /&gt;
            base.OnInit(e);&lt;br /&gt;
        }&lt;br /&gt;
        protected override object SaveControlState()&lt;br /&gt;
        {&lt;br /&gt;
            return _strStateToSave;&lt;br /&gt;
        }&lt;br /&gt;
        protected override void LoadControlState(object state)&lt;br /&gt;
        {&lt;br /&gt;
            if (state != null)&lt;br /&gt;
            {&lt;br /&gt;
                _strStateToSave = state.ToString();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== Query Strings ===&lt;br /&gt;
[[ASP.NET Query Strings|Query string]] is one of the techniques in Web applications to send data from one page to another. A query string consists of two parts, field and value, and each of pair separated by ampersand (&amp;amp;). The ?(question mark in a query string indicates the beginning of a query string and it's value.&lt;br /&gt;
&lt;br /&gt;
== Server-side | Technique ==&lt;br /&gt;
=== Session State ===&lt;br /&gt;
==== InProc ====&lt;br /&gt;
==== OutProc ====&lt;br /&gt;
ASP.NET session state is designed to enable you to easily store user session data in different sources for your ASP.NET applications. By default, session state values and information are stored in memory within the ASP.NET process. Alternatively, you can store [[OutProc Session SQLServer|session data in a SQL Server database]], where it can be shared by multiple Web servers. For more information about session state, see Implementing a Session-State Store Provider and Session-State Modes.&lt;br /&gt;
&lt;br /&gt;
=== Application State ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=OutProc_Session_SQLServer&amp;diff=148</id>
		<title>OutProc Session SQLServer</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=OutProc_Session_SQLServer&amp;diff=148"/>
		<updated>2022-08-03T10:47:17Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ASP.NET session state is designed to enable you to easily store user session data in different sources for your ASP.NET applications. By default, session state values and information are stored in memory within the ASP.NET process. Alternatively, you can store session data in a SQL Server database, where it can be shared by multiple Web servers. For more information about session state, see Implementing a Session-State Store Provider and Session-State Modes.&lt;br /&gt;
&lt;br /&gt;
=== Configure SQL Server to store ASP.NET session state ===&lt;br /&gt;
&lt;br /&gt;
Before you can actually store a session state in SQL server, you need to configure it. This configuration is done via a command line tool called ASPNET_REGSQL.EXE. You can store the session state in three possible locations within the SQL Server:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command !! Description&lt;br /&gt;
|-&lt;br /&gt;
| -S &amp;lt;server&amp;gt; || Species the IP address or the name of SQL server in which you want to store the session state&lt;br /&gt;
|-&lt;br /&gt;
| -U || Specifies the user ID to be used when connecting to the SQL Server&lt;br /&gt;
|-&lt;br /&gt;
| -P || Specifies the password to be used when connecting to the SQL Server&lt;br /&gt;
|-&lt;br /&gt;
| -E || Indicates that you want to use integrated security when connecting to the SQL Server&lt;br /&gt;
|-&lt;br /&gt;
| -ssadd || Adds support for the SQLServer mode session state&lt;br /&gt;
|-&lt;br /&gt;
| -ssremove || Removes support for the SQLServer mode session state&lt;br /&gt;
|-&lt;br /&gt;
| -sstype || Type of session state support. This option can be:&amp;lt;br&amp;gt;&lt;br /&gt;
t for temporary storage&amp;lt;br&amp;gt;&lt;br /&gt;
p for persistent storage&amp;lt;br&amp;gt;&lt;br /&gt;
c for custom storage&lt;br /&gt;
|-&lt;br /&gt;
| -d&amp;lt;br&amp;gt;&amp;lt;database&amp;gt; || The name of the custom database to use if -sstype switch is &amp;quot;c&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It opens command prompt.  Type the following command to create the SQL State Database tables and procedures.&lt;br /&gt;
&lt;br /&gt;
'''C:\%windir%\Microsoft.NET\Framework\&amp;lt;versionNumber&amp;gt;\'''&lt;br /&gt;
&lt;br /&gt;
For creating default Database for SQL State.&lt;br /&gt;
&lt;br /&gt;
'''aspnet_regsql.exe -S XXXXX -U XX -P XXXXXXXXX -ssadd -sstype p'''&lt;br /&gt;
&lt;br /&gt;
Update &amp;lt;sessionState&amp;gt; tag in '''web.congif'''&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;system.web&amp;gt;&lt;br /&gt;
  &amp;lt;sessionState mode=&amp;quot;SQLServer&amp;quot; sqlConnectionString=&amp;quot;data source=DESKTOP-ABGPQE5; user id=sa;password=XXXXXXXXX;&amp;quot; cookieless=&amp;quot;false&amp;quot; timeout=&amp;quot;20&amp;quot;/&amp;gt;    &lt;br /&gt;
  &amp;lt;/system.web&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=OutProc_Session_SQLServer&amp;diff=147</id>
		<title>OutProc Session SQLServer</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=OutProc_Session_SQLServer&amp;diff=147"/>
		<updated>2022-07-29T15:29:16Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;ASP.NET session state is designed to enable you to easily store user session data in different sources for your ASP.NET applications. By default, session state values and info...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ASP.NET session state is designed to enable you to easily store user session data in different sources for your ASP.NET applications. By default, session state values and information are stored in memory within the ASP.NET process. Alternatively, you can store session data in a SQL Server database, where it can be shared by multiple Web servers. For more information about session state, see Implementing a Session-State Store Provider and Session-State Modes.&lt;br /&gt;
&lt;br /&gt;
=== Configure SQL Server to store ASP.NET session state ===&lt;br /&gt;
&lt;br /&gt;
Before you can actually store a session state in SQL server, you need to configure it. This configuration is done via a command line tool called ASPNET_REGSQL.EXE. You can store the session state in three possible locations within the SQL Server:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Command !! Description&lt;br /&gt;
|-&lt;br /&gt;
| -S &amp;lt;server&amp;gt; || Species the IP address or the name of SQL server in which you want to store the session state&lt;br /&gt;
|-&lt;br /&gt;
| -U || Specifies the user ID to be used when connecting to the SQL Server&lt;br /&gt;
|-&lt;br /&gt;
| -P || Specifies the password to be used when connecting to the SQL Server&lt;br /&gt;
|-&lt;br /&gt;
| -E || Indicates that you want to use integrated security when connecting to the SQL Server&lt;br /&gt;
|-&lt;br /&gt;
| -ssadd || Adds support for the SQLServer mode session state&lt;br /&gt;
|-&lt;br /&gt;
| -ssremove || Removes support for the SQLServer mode session state&lt;br /&gt;
|-&lt;br /&gt;
| -sstype || Type of session state support. This option can be:&amp;lt;br&amp;gt;&lt;br /&gt;
t for temporary storage&amp;lt;br&amp;gt;&lt;br /&gt;
p for persistent storage&amp;lt;br&amp;gt;&lt;br /&gt;
c for custom storage&lt;br /&gt;
|-&lt;br /&gt;
| -d&amp;lt;br&amp;gt;&amp;lt;database&amp;gt; || The name of the custom database to use if -sstype switch is &amp;quot;c&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
It opens command prompt.  Type the following command to create the SQL State Database tables and procedures.&lt;br /&gt;
&lt;br /&gt;
'''C:\%windir%\Microsoft.NET\Framework\&amp;lt;versionNumber&amp;gt;\'''&lt;br /&gt;
&lt;br /&gt;
For creating default Database for SQL State.&lt;br /&gt;
&lt;br /&gt;
'''aspnet_regsql.exe -S XXXXX -U XX -P XXXXXXXXX -ssadd -sstype p'''&lt;br /&gt;
&lt;br /&gt;
Update &amp;lt;sessionState&amp;gt; tag in '''web.congif'''&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;system.web&amp;gt;&lt;br /&gt;
  &amp;lt;sessionState mode=&amp;quot;SQLServer&amp;quot; sqlConnectionString=&amp;quot;data source=DESKTOP-ABGPQE5; user id=sa;password=9fc300a7;&amp;quot; cookieless=&amp;quot;false&amp;quot; timeout=&amp;quot;20&amp;quot;/&amp;gt;    &lt;br /&gt;
  &amp;lt;/system.web&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Threading&amp;diff=146</id>
		<title>Threading</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Threading&amp;diff=146"/>
		<updated>2020-11-29T18:14:16Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Methods of Thread */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;.Net supports parallel execution through multithreading. A thread is an independent execution path, able to run simultaneously with other threads. A client program starts in a single thread(the “main” thread) created by the CLR/Operating System and and we can make it a multithreaded program by creating additional threads.&lt;br /&gt;
    using System;&lt;br /&gt;
    using System.Threading;&lt;br /&gt;
    namespace ConsoleAppThread&lt;br /&gt;
    {&lt;br /&gt;
        class Program&lt;br /&gt;
        {&lt;br /&gt;
            static void Main()&lt;br /&gt;
            {&lt;br /&gt;
                Thread childThread = new Thread(WriteY); // Create a new thread&lt;br /&gt;
                childThread.Start(); // running childThread()&lt;br /&gt;
                                     // Simultaneously, do run on the main thread.&lt;br /&gt;
            for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Main Thread..&amp;quot;);&lt;br /&gt;
                Console.ReadLine();&lt;br /&gt;
            }&lt;br /&gt;
            static void WriteY()&lt;br /&gt;
            {&lt;br /&gt;
                for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Child Thread..&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
The main thread creates a new thread(Child Thread) on which it runs a method that repeatedly prints &amp;quot;Child Thread..&amp;quot;. Simultaneously, the main thread repeatedly prints the character &amp;quot;Main Thread..&amp;quot;. Here is the output:&lt;br /&gt;
    Child Thread..Child Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread...............Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread........Main Thread..Main Thread..Main Thread..Main Thread.........Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread............&lt;br /&gt;
== Properties of Thread ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No. !! Property !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || ApartmentState || Gets or sets the apartment state of this thread.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CurrentContext || Gets the current context in which the thread is executing.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || CurrentCulture || Gets or sets the culture for the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CurrentPrinciple || Gets or sets the thread's current principal (for role-based security).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || CurrentThread || Gets the currently running thread.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || CurrentUICulture || Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || ExecutionContext || Gets an ExecutionContext object that contains information about the various contexts of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 8  || IsAlive || Gets a value indicating the execution status of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
|  9 || IsBackground || Gets or sets a value indicating whether or not a thread is a background thread.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || IsThreadPoolThread || Gets a value indicating whether or not a thread belongs to the managed thread pool.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || ManagedThreadId || Gets a unique identifier for the current managed thread.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Name || Gets or sets the name of the thread.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Priority || Gets or sets a value indicating the scheduling priority of a thread.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || ThreadState || Gets a value containing the states of the current thread.&lt;br /&gt;
|}&lt;br /&gt;
== Methods of Thread ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No. !! Methods and Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || '''public void Abort()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || '''public static LocalDataStoreSlot AllocateDataSlot()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Allocates an unnamed data slot on all the threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || '''public static LocalDataStoreSlot AllocateNamedDataSlot(string name)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Allocates a named data slot on all threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || '''public static void BeginCriticalRegion()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception might jeopardize other tasks in the application domain.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || '''public static void BeginThreadAffinity()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Notifies a host that managed code is about to execute instructions that depend on the identity of the current physical operating system thread.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || '''public static void EndCriticalRegion()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception are limited to the current task.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || '''public static void EndThreadAffinity()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Notifies a host that managed code has finished executing instructions that depend on the identity of the current physical operating system thread.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || '''public static void FreeNamedDataSlot(string name)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Eliminates the association between a name and a slot, for all threads in the process. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || '''public static Object GetData(LocalDataStoreSlot slot)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Retrieves the value from the specified slot on the current thread, within the current thread's current domain. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || '''public static AppDomain GetDomain()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Returns the current domain in which the current thread is running.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || '''public static AppDomain GetDomainID()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Returns a unique application domain identifier&lt;br /&gt;
|-&lt;br /&gt;
| 12 || '''public static LocalDataStoreSlot GetNamedDataSlot(string name)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Looks up a named data slot. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || '''public void Interrupt()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Interrupts a thread that is in the WaitSleepJoin thread state.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || '''public void Join()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Blocks the calling thread until a thread terminates, while continuing to perform standard COM and SendMessage pumping. This method has different overloaded forms.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || '''public static void MemoryBarrier()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Synchronizes memory access as follows: The processor executing the current thread cannot reorder instructions in such a way that memory accesses prior to the call to MemoryBarrier execute after memory accesses that follow the call to MemoryBarrier.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || '''public static void ResetAbort()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Cancels an Abort requested for the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 17 || '''public static void SetData(LocalDataStoreSlot slot, Object data)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Sets the data in the specified slot on the currently running thread, for that thread's current domain. For better performance, use fields marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 18 || '''public void Start()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Starts a thread.&lt;br /&gt;
|-&lt;br /&gt;
| 19 || '''public static void Sleep(int millisecondsTimeout)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Makes the thread pause for a period of time.&lt;br /&gt;
|-&lt;br /&gt;
| 20 || '''public static void SpinWait(int iterations)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Causes a thread to wait the number of times defined by the iterations parameter&lt;br /&gt;
|-&lt;br /&gt;
| 21 || '''public static byte VolatileRead(ref byte address)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'''public static double VolatileRead(ref double address)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'''public static int VolatileRead(ref int address)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'''public static Object VolatileRead(ref Object address)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Reads the value of a field. The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache. This method has different overloaded forms. Only some are given above.&lt;br /&gt;
|-&lt;br /&gt;
| 22 || '''public static void VolatileWrite(ref byte address,byte value)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''public static void VolatileWrite(ref double address, double value)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''public static void VolatileWrite(ref int address, int value)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''public static void VolatileWrite(ref Object address, Object value)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Writes a value to a field immediately, so that the value is visible to all processors in the computer. This method has different overloaded forms. Only some are given above.&lt;br /&gt;
|-&lt;br /&gt;
| 23 || '''public static bool Yield()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the thread to yield to.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Threading&amp;diff=145</id>
		<title>Threading</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Threading&amp;diff=145"/>
		<updated>2020-11-29T16:52:45Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;.Net supports parallel execution through multithreading. A thread is an independent execution path, able to run simultaneously with other threads. A client program starts in a single thread(the “main” thread) created by the CLR/Operating System and and we can make it a multithreaded program by creating additional threads.&lt;br /&gt;
    using System;&lt;br /&gt;
    using System.Threading;&lt;br /&gt;
    namespace ConsoleAppThread&lt;br /&gt;
    {&lt;br /&gt;
        class Program&lt;br /&gt;
        {&lt;br /&gt;
            static void Main()&lt;br /&gt;
            {&lt;br /&gt;
                Thread childThread = new Thread(WriteY); // Create a new thread&lt;br /&gt;
                childThread.Start(); // running childThread()&lt;br /&gt;
                                     // Simultaneously, do run on the main thread.&lt;br /&gt;
            for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Main Thread..&amp;quot;);&lt;br /&gt;
                Console.ReadLine();&lt;br /&gt;
            }&lt;br /&gt;
            static void WriteY()&lt;br /&gt;
            {&lt;br /&gt;
                for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Child Thread..&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
The main thread creates a new thread(Child Thread) on which it runs a method that repeatedly prints &amp;quot;Child Thread..&amp;quot;. Simultaneously, the main thread repeatedly prints the character &amp;quot;Main Thread..&amp;quot;. Here is the output:&lt;br /&gt;
    Child Thread..Child Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread...............Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread........Main Thread..Main Thread..Main Thread..Main Thread.........Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread............&lt;br /&gt;
== Properties of Thread ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No. !! Property !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || ApartmentState || Gets or sets the apartment state of this thread.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CurrentContext || Gets the current context in which the thread is executing.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || CurrentCulture || Gets or sets the culture for the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CurrentPrinciple || Gets or sets the thread's current principal (for role-based security).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || CurrentThread || Gets the currently running thread.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || CurrentUICulture || Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || ExecutionContext || Gets an ExecutionContext object that contains information about the various contexts of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 8  || IsAlive || Gets a value indicating the execution status of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
|  9 || IsBackground || Gets or sets a value indicating whether or not a thread is a background thread.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || IsThreadPoolThread || Gets a value indicating whether or not a thread belongs to the managed thread pool.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || ManagedThreadId || Gets a unique identifier for the current managed thread.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Name || Gets or sets the name of the thread.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Priority || Gets or sets a value indicating the scheduling priority of a thread.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || ThreadState || Gets a value containing the states of the current thread.&lt;br /&gt;
|}&lt;br /&gt;
== Methods of Thread ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No. !! Methods and Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || '''public void Abort()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || '''public static LocalDataStoreSlot AllocateDataSlot()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Allocates an unnamed data slot on all the threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || '''public static LocalDataStoreSlot AllocateNamedDataSlot(string name)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Allocates a named data slot on all threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || '''public static void BeginCriticalRegion()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception might jeopardize other tasks in the application domain.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || '''public static void BeginThreadAffinity()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Notifies a host that managed code is about to execute instructions that depend on the identity of the current physical operating system thread.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || '''public static void EndCriticalRegion()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception are limited to the current task.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || '''public static void EndThreadAffinity()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Notifies a host that managed code has finished executing instructions that depend on the identity of the current physical operating system thread.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || '''public static void FreeNamedDataSlot(string name)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Eliminates the association between a name and a slot, for all threads in the process. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || '''public static Object GetData(LocalDataStoreSlot slot)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Retrieves the value from the specified slot on the current thread, within the current thread's current domain. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || '''public static AppDomain GetDomain()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Returns the current domain in which the current thread is running.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || '''public static AppDomain GetDomainID()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Returns a unique application domain identifier&lt;br /&gt;
|-&lt;br /&gt;
| 12 || '''public static LocalDataStoreSlot GetNamedDataSlot(string name)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Looks up a named data slot. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || '''public void Interrupt()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Interrupts a thread that is in the WaitSleepJoin thread state.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || '''public void Join()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Blocks the calling thread until a thread terminates, while continuing to perform standard COM and SendMessage pumping. This method has different overloaded forms.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || '''public static void MemoryBarrier()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Synchronizes memory access as follows: The processor executing the current thread cannot reorder instructions in such a way that memory accesses prior to the call to MemoryBarrier execute after memory accesses that follow the call to MemoryBarrier.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || '''public static void ResetAbort()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Cancels an Abort requested for the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 17 || '''public static void SetData(LocalDataStoreSlot slot, Object data)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Sets the data in the specified slot on the currently running thread, for that thread's current domain. For better performance, use fields marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 18 || '''public void Start()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Starts a thread.&lt;br /&gt;
|-&lt;br /&gt;
| 19 || '''public static void Sleep(int millisecondsTimeout)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Makes the thread pause for a period of time.&lt;br /&gt;
|-&lt;br /&gt;
| 20 || '''public static void SpinWait(int iterations)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Causes a thread to wait the number of times defined by the iterations parameter&lt;br /&gt;
|-&lt;br /&gt;
| 21 || '''public static byte VolatileRead(ref byte address)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'''public static double VolatileRead(ref double address)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'''public static int VolatileRead(ref int address)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'''public static Object VolatileRead(ref Object address)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Reads the value of a field. The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache. This method has different overloaded forms. Only some are given above.&lt;br /&gt;
|-&lt;br /&gt;
| 22 || '''public static void VolatileWrite(ref byte address,byte value)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''public static void VolatileWrite(ref double address, double value)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''public static void VolatileWrite(ref int address, int value)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''public static void VolatileWrite(ref Object address, Object value)'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Writes a value to a field immediately, so that the value is visible to all processors in the computer. This method has different overloaded forms. Only some are given above.&lt;br /&gt;
|-&lt;br /&gt;
| 23 || '''public static bool Yield()'''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the thread to yield to.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Threading&amp;diff=144</id>
		<title>Threading</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Threading&amp;diff=144"/>
		<updated>2020-11-29T05:33:49Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;.Net supports parallel execution through multithreading. A thread is an independent execution path, able to run simultaneously with other threads. A client program starts in a single thread(the “main” thread) created by the CLR/Operating System and and we can make it a multithreaded program by creating additional threads.&lt;br /&gt;
    using System;&lt;br /&gt;
    using System.Threading;&lt;br /&gt;
    namespace ConsoleAppThread&lt;br /&gt;
    {&lt;br /&gt;
        class Program&lt;br /&gt;
        {&lt;br /&gt;
            static void Main()&lt;br /&gt;
            {&lt;br /&gt;
                Thread childThread = new Thread(WriteY); // Create a new thread&lt;br /&gt;
                childThread.Start(); // running childThread()&lt;br /&gt;
                                     // Simultaneously, do run on the main thread.&lt;br /&gt;
            for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Main Thread..&amp;quot;);&lt;br /&gt;
                Console.ReadLine();&lt;br /&gt;
            }&lt;br /&gt;
            static void WriteY()&lt;br /&gt;
            {&lt;br /&gt;
                for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Child Thread..&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
The main thread creates a new thread(Child Thread) on which it runs a method that repeatedly prints &amp;quot;Child Thread..&amp;quot;. Simultaneously, the main thread repeatedly prints the character &amp;quot;Main Thread..&amp;quot;. Here is the output:&lt;br /&gt;
    Child Thread..Child Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread...............Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread........Main Thread..Main Thread..Main Thread..Main Thread.........Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread............&lt;br /&gt;
== Properties of Thread ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No. !! Property !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || ApartmentState || Gets or sets the apartment state of this thread.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CurrentContext || Gets the current context in which the thread is executing.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || CurrentCulture || Gets or sets the culture for the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CurrentPrinciple || Gets or sets the thread's current principal (for role-based security).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || CurrentThread || Gets the currently running thread.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || CurrentUICulture || Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || ExecutionContext || Gets an ExecutionContext object that contains information about the various contexts of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 8  || IsAlive || Gets a value indicating the execution status of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
|  9 || IsBackground || Gets or sets a value indicating whether or not a thread is a background thread.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || IsThreadPoolThread || Gets a value indicating whether or not a thread belongs to the managed thread pool.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || ManagedThreadId || Gets a unique identifier for the current managed thread.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Name || Gets or sets the name of the thread.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Priority || Gets or sets a value indicating the scheduling priority of a thread.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || ThreadState || Gets a value containing the states of the current thread.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Threading&amp;diff=143</id>
		<title>Threading</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Threading&amp;diff=143"/>
		<updated>2020-11-29T05:33:30Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;.Net supports parallel execution through multithreading. A thread is an independent execution path, able to run simultaneously with other threads. A client program starts in a single thread(the “main” thread) created by the CLR/Operating System and and we can make it a multithreaded program by creating additional threads.&lt;br /&gt;
    using System;&lt;br /&gt;
    using System.Threading;&lt;br /&gt;
    namespace ConsoleAppThread&lt;br /&gt;
    {&lt;br /&gt;
        class Program&lt;br /&gt;
        {&lt;br /&gt;
            static void Main()&lt;br /&gt;
            {&lt;br /&gt;
                Thread childThread = new Thread(WriteY); // Create a new thread&lt;br /&gt;
                childThread.Start(); // running childThread()&lt;br /&gt;
                                     // Simultaneously, do run on the main thread.&lt;br /&gt;
            for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Main Thread..&amp;quot;);&lt;br /&gt;
                Console.ReadLine();&lt;br /&gt;
            }&lt;br /&gt;
            static void WriteY()&lt;br /&gt;
            {&lt;br /&gt;
                for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Child Thread..&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
The main thread creates a new thread(Child Thread) on which it runs a method that repeatedly prints &amp;quot;Child Thread..&amp;quot;. Simultaneously, the main thread repeatedly prints the character &amp;quot;Main Thread..&amp;quot;. Here is the output:&lt;br /&gt;
    Child Thread..Child Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread...............Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread........Main Thread..Main Thread..Main Thread..Main Thread.........Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread............&lt;br /&gt;
== Properties of Thread ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No. !! Property !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || ApartmentState || Gets or sets the apartment state of this thread.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CurrentContext || Gets the current context in which the thread is executing.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || CurrentCulture || Gets or sets the culture for the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CurrentPrinciple || Gets or sets the thread's current principal (for role-based security).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || CurrentThread || Gets the currently running thread.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || CurrentUICulture || Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || ExecutionContext || Gets an ExecutionContext object that contains information about the various contexts of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 8  || IsAlive || Gets a value indicating the execution status of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
|  9 || IsBackground || Gets or sets a value indicating whether or not a thread is a background thread.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || IsThreadPoolThread || Gets a value indicating whether or not a thread belongs to the managed thread pool.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || ManagedThreadId || Gets a unique identifier for the current managed thread.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Name || Gets or sets the name of the thread.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Priority || Gets or sets a value indicating the scheduling priority of a thread.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || ThreadState || Gets a value containing the states of the current thread.&lt;br /&gt;
|}&lt;br /&gt;
== Methods of Thread ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No. !! Method !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || public void Abort() || Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || public static LocalDataStoreSlot AllocateDataSlot() || Allocates an unnamed data slot on all the threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || public static LocalDataStoreSlot AllocateNamedDataSlot(string name)|| Allocates a named data slot on all threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || public static void BeginCriticalRegion() || Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception might jeopardize other tasks in the application domain.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || public static void BeginThreadAffinity() || Notifies a host that managed code is about to execute instructions that depend on the identity of the current physical operating system thread.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || public static void EndCriticalRegion() || Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception are limited to the current task.&lt;br /&gt;
|-&lt;br /&gt;
| 7  || public static void EndThreadAffinity() || Notifies a host that managed code has finished executing instructions that depend on the identity of the current physical operating system thread.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || public static void FreeNamedDataSlot(string name) || Eliminates the association between a name and a slot, for all threads in the process. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || public static Object GetData(LocalDataStoreSlot slot) || Retrieves the value from the specified slot on the current thread, within the current thread's current domain. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || public static AppDomain GetDomain() || Returns the current domain in which the current thread is running.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || public static AppDomain GetDomainID() || Returns a unique application domain identifier&lt;br /&gt;
|-&lt;br /&gt;
| 12 || public static LocalDataStoreSlot GetNamedDataSlot(string name) || Looks up a named data slot. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || public void Interrupt() || Interrupts a thread that is in the WaitSleepJoin thread state.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || public void Join() || Blocks the calling thread until a thread terminates, while continuing to perform standard COM and SendMessage pumping. This method has different overloaded forms.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || public static void MemoryBarrier() || Synchronizes memory access as follows: The processor executing the current thread cannot reorder instructions in such a way that memory accesses prior to the call to MemoryBarrier execute after memory accesses that follow the call to MemoryBarrier.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || public static void ResetAbort() || Cancels an Abort requested for the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 17 || public static void SetData(LocalDataStoreSlot slot, Object data) || Sets the data in the specified slot on the currently running thread, for that thread's current domain. For better performance, use fields marked with the ThreadStaticAttribute attribute instead.&lt;br /&gt;
|-&lt;br /&gt;
| 18 || public void Start() || Starts a thread.&lt;br /&gt;
|-&lt;br /&gt;
| 19 || public static void Sleep(int millisecondsTimeout) || Makes the thread pause for a period of time.&lt;br /&gt;
|-&lt;br /&gt;
| 20 || public static void SpinWait(int iterations) || Causes a thread to wait the number of times defined by the iterations parameter&lt;br /&gt;
|-&lt;br /&gt;
| 21 || public static byte VolatileRead(ref byte address)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;public static double VolatileRead(ref double address)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;public static int VolatileRead(ref int address)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;public static Object VolatileRead(ref Object address) || Reads the value of a field. The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache. This method has different overloaded forms. Only some are given above.&lt;br /&gt;
|-&lt;br /&gt;
| 22 || public static void VolatileWrite(ref byte address,byte value)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;public static void VolatileWrite(ref double address, double value)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;public static void VolatileWrite(ref int address, int value)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;public static void VolatileWrite(ref Object address, Object value) || Writes a value to a field immediately, so that the value is visible to all processors in the computer. This method has different overloaded forms. Only some are given above.&lt;br /&gt;
|-&lt;br /&gt;
| 23 || public static bool Yield() || Causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the thread to yield to.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Threading&amp;diff=142</id>
		<title>Threading</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Threading&amp;diff=142"/>
		<updated>2020-11-28T16:43:03Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;.Net supports parallel execution through multithreading. A thread is an independent execution path, able to run simultaneously with other threads. A client program starts in a...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;.Net supports parallel execution through multithreading. A thread is an independent execution path, able to run simultaneously with other threads. A client program starts in a single thread(the “main” thread) created by the CLR/Operating System and and we can make it a multithreaded program by creating additional threads.&lt;br /&gt;
    using System;&lt;br /&gt;
    using System.Threading;&lt;br /&gt;
    namespace ConsoleAppThread&lt;br /&gt;
    {&lt;br /&gt;
        class Program&lt;br /&gt;
        {&lt;br /&gt;
            static void Main()&lt;br /&gt;
            {&lt;br /&gt;
                Thread childThread = new Thread(WriteY); // Create a new thread&lt;br /&gt;
                childThread.Start(); // running childThread()&lt;br /&gt;
                                     // Simultaneously, do run on the main thread.&lt;br /&gt;
            for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Main Thread..&amp;quot;);&lt;br /&gt;
                Console.ReadLine();&lt;br /&gt;
            }&lt;br /&gt;
            static void WriteY()&lt;br /&gt;
            {&lt;br /&gt;
                for (int i = 0; i &amp;lt; 100; i++) Console.Write(&amp;quot;Child Thread..&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
The main thread creates a new thread(Child Thread) on which it runs a method that repeatedly prints &amp;quot;Child Thread..&amp;quot;. Simultaneously, the main thread repeatedly prints the character &amp;quot;Main Thread..&amp;quot;. Here is the output:&lt;br /&gt;
    Child Thread..Child Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread..Main Thread...............Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread........Main Thread..Main Thread..Main Thread..Main Thread.........Child Thread..Child Thread..Child Thread..Child Thread..Child Thread..Child Thread............&lt;br /&gt;
== Properties of Thread ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No. !! Property !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || ApartmentState || Gets or sets the apartment state of this thread.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CurrentContext || Gets the current context in which the thread is executing.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || CurrentCulture || Gets or sets the culture for the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CurrentPrinciple || Gets or sets the thread's current principal (for role-based security).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || CurrentThread || Gets the currently running thread.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || CurrentUICulture || Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || ExecutionContext || Gets an ExecutionContext object that contains information about the various contexts of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
| 8  || IsAlive || Gets a value indicating the execution status of the current thread.&lt;br /&gt;
|-&lt;br /&gt;
|  9 || IsBackground || Gets or sets a value indicating whether or not a thread is a background thread.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || IsThreadPoolThread || Gets a value indicating whether or not a thread belongs to the managed thread pool.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || ManagedThreadId || Gets a unique identifier for the current managed thread.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Name || Gets or sets the name of the thread.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Priority || Gets or sets a value indicating the scheduling priority of a thread.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || ThreadState || Gets a value containing the states of the current thread.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Builder_Design_Pattern&amp;diff=141</id>
		<title>Builder Design Pattern</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Builder_Design_Pattern&amp;diff=141"/>
		<updated>2020-10-19T17:45:20Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Builder pattern aims to &amp;quot;Separate the construction of a complex object&amp;quot;. It was was introduced to solve some of the problems with Factory and Abstract Factory design patterns when the Object contains a lot of attributes. &lt;br /&gt;
&lt;br /&gt;
In other words, it is used to construct a complex object step by step and the final step will return the object. The process of constructing an object should be generic so that it can be used to create different representations of the same object.&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
== Code Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
* Code is more maintainable and readable.&lt;br /&gt;
* Less chances of error as we have distributed a complex object to few simple objects.&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
Number of lines of code increases in builder pattern, but it makes sense as the effort pays off in terms of maintainability and readability.&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
If your object has only a few constructor arguments, it makes no sense to use the builder pattern.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Design_Patterns&amp;diff=140</id>
		<title>Design Patterns</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Design_Patterns&amp;diff=140"/>
		<updated>2020-10-19T16:21:34Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Design patterns provide general '''solutions to software design problems''' we find in real-world application development.&lt;br /&gt;
&lt;br /&gt;
Before starting with design patterns let's understand what the meaning of design patterns and why they are useful in software programming/architecture.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Each pattern describes a problem that occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.&amp;quot; - Christopher Alexander, A Pattern Language.&lt;br /&gt;
&lt;br /&gt;
It is important to understand design patterns rather than memorizing their classes, methods and properties. First identify the software design problem then see how to address these problems using design patterns and determine the best suited design problem to solve the problem.&lt;br /&gt;
&lt;br /&gt;
There are 23 design patterns, also known as '''Gang of Four (GoF)''' design patterns. The Gang of Four are the authors of the book, &amp;quot;Design Patterns: Elements of Reusable Object Oriented Software&amp;quot;.&lt;br /&gt;
[[File:Design Patterns.png|none|Design Patterns &amp;amp; Types of Design Patterns]]&lt;br /&gt;
&lt;br /&gt;
== Creational Design Pattern ==&lt;br /&gt;
In software engineering, creational design patterns are design patterns that deal with '''object creation mechanisms''', trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.&lt;br /&gt;
=== Simple Factory ===&lt;br /&gt;
[[Simple Factory Pattern]] returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and common methods, but each may perform a task differently or optimize for different data or behaviors.&lt;br /&gt;
&lt;br /&gt;
=== Factory Method ===&lt;br /&gt;
The [[Factory Method Design Pattern|factory method pattern]] is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory method—either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes—rather than by calling a constructor.&lt;br /&gt;
&lt;br /&gt;
=== Abstract Factory ===&lt;br /&gt;
The [[Abstract Factory Design Pattern|abstract factory pattern]] provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part of the theme. The client doesn't know or care which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
In simple words, It provides an interface for creating families of related or dependent objects without specifying their concrete classes.&lt;br /&gt;
&lt;br /&gt;
=== Builder ===&lt;br /&gt;
The [[Builder Design Pattern|Builder]] is a design pattern designed to provide a flexible solution to various object creation problems in object-oriented programming. The intent of the Builder design pattern is to separate the construction of a complex object from its representation.&lt;br /&gt;
&lt;br /&gt;
In simple words, separating the construction of a complex object from its representation so that the same construction process can create different representations.&lt;br /&gt;
&lt;br /&gt;
=== Prototype ===&lt;br /&gt;
The [[Prototype Design Pattern|prototype pattern]] is a creational design pattern in software development. It is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects.&lt;br /&gt;
&lt;br /&gt;
In simple words, specifying the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.&lt;br /&gt;
&lt;br /&gt;
=== Singleton ===&lt;br /&gt;
The [[Singleton Design Pattern|singleton pattern]] is a software design pattern that restricts the instantiation of a class to one '''single''' instance. This is useful when exactly one object is needed to coordinate actions across the system.&lt;br /&gt;
&lt;br /&gt;
== Structural Design Patterns ==&lt;br /&gt;
=== Adapter ===&lt;br /&gt;
=== Bridge ===&lt;br /&gt;
=== Composite ===&lt;br /&gt;
=== Decorator ===&lt;br /&gt;
=== Façade ===&lt;br /&gt;
=== Flyweight ===&lt;br /&gt;
=== Proxy ===&lt;br /&gt;
== Behavioral Design Patterns ==&lt;br /&gt;
=== Chain of Responsibility ===&lt;br /&gt;
=== Command ===&lt;br /&gt;
=== Interpreter ===&lt;br /&gt;
=== Iterator ===&lt;br /&gt;
=== Mediator ===&lt;br /&gt;
=== Memento ===&lt;br /&gt;
=== Observer ===&lt;br /&gt;
=== State ===&lt;br /&gt;
=== Strategy ===&lt;br /&gt;
=== Visitor ===&lt;br /&gt;
=== Template Method ===&lt;br /&gt;
== Note ==&lt;br /&gt;
We should not use Design Pattern just because it is a Design Pattern as no one should follow the best practice just because it is a best practice.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Changing_the_color_of_title_bar_(Non_Client_Area)&amp;diff=139</id>
		<title>Changing the color of title bar (Non Client Area)</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Changing_the_color_of_title_bar_(Non_Client_Area)&amp;diff=139"/>
		<updated>2020-10-19T16:05:38Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If we want to custamize the title of our windows form, then it can be done easily with third party tools like DevExpress if we can afford it. We don't make a borderless form as we will lose all functionality from the form like minimize/maximize fade transitions.&lt;br /&gt;
&lt;br /&gt;
Despite all of the above there are ways to change the color of the application title bar in WinForms. However, there are lot of issues.&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
    using System.Drawing;&lt;br /&gt;
    using System.Windows.Forms;&lt;br /&gt;
    namespace ColorFramework&lt;br /&gt;
    {&lt;br /&gt;
        public class ColorSkinBase&lt;br /&gt;
        {&lt;br /&gt;
            // A form with custom border and title bar.&lt;br /&gt;
            // Some functions, such as resize the window via mouse, are not implemented yet. &lt;br /&gt;
            // Color color = (Color)ColorConverter.ConvertFromString(&amp;quot;#FFDFD991&amp;quot;);&lt;br /&gt;
            //Color colour = ColorTranslator.FromHtml(&amp;quot;#E7EFF2&amp;quot;);&lt;br /&gt;
            // The color and the width of the border.&lt;br /&gt;
            private Color borderColor;// = Color.GreenYellow;&lt;br /&gt;
            private int borderWidth = 3;&lt;br /&gt;
            // The color and region of the header.&lt;br /&gt;
            private Color headerColor;// = ColorTranslator.FromHtml(&amp;quot;#ff0000&amp;quot;);// Color.Red;&lt;br /&gt;
            private Rectangle headerRect;&lt;br /&gt;
            // The region of the client.&lt;br /&gt;
            private Rectangle clientRect;&lt;br /&gt;
            // The region of the title text.&lt;br /&gt;
            private Rectangle titleRect;&lt;br /&gt;
            // The region of the minimum button.&lt;br /&gt;
            private Rectangle miniBoxRect;&lt;br /&gt;
            // The region of the maximum button.&lt;br /&gt;
            private Rectangle maxBoxRect;&lt;br /&gt;
            // The region of the close button.&lt;br /&gt;
            private Rectangle closeBoxRect;&lt;br /&gt;
            // The states of the three header buttons.&lt;br /&gt;
            private ButtonState miniState;&lt;br /&gt;
            private ButtonState maxState;&lt;br /&gt;
            private ButtonState closeState;&lt;br /&gt;
            // Store the mouse down point to handle moving the form.&lt;br /&gt;
            private int x = 0;&lt;br /&gt;
            private int y = 0;&lt;br /&gt;
            // The height of the header.&lt;br /&gt;
            const int HEADER_HEIGHT = 25;&lt;br /&gt;
            // The size of the header buttons.&lt;br /&gt;
            private readonly Size BUTTON_BOX_SIZE = new Size(15, 15);&lt;br /&gt;
            private System.Windows.Forms.Form _parentForm;&lt;br /&gt;
            public ColorSkinBase(System.Windows.Forms.Form ParentForm, Color borderColor, Color headerColor)&lt;br /&gt;
            {&lt;br /&gt;
                this._parentForm = ParentForm;&lt;br /&gt;
                this.borderColor = borderColor;&lt;br /&gt;
                this.headerColor = headerColor;&lt;br /&gt;
                _parentForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;&lt;br /&gt;
                _parentForm.Paint += new System.Windows.Forms.PaintEventHandler(this.CustomBorderColorForm_Paint);&lt;br /&gt;
                _parentForm.Resize += new System.EventHandler(this.CustomBorderColorForm_Resize);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseDown);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseMove);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseUp);&lt;br /&gt;
                _parentForm.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseDoubleClick);&lt;br /&gt;
            }&lt;br /&gt;
            //private void Form1_Load(System.Object sender, System.EventArgs e)&lt;br /&gt;
            //{&lt;br /&gt;
            //    // Hide the border and the title bar.&lt;br /&gt;
            //    _parentForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;&lt;br /&gt;
            //}&lt;br /&gt;
            private void CustomBorderColorForm_Paint(System.Object sender, System.Windows.Forms.PaintEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Draw the header.&lt;br /&gt;
                using (Brush b = new SolidBrush(borderColor))&lt;br /&gt;
                {&lt;br /&gt;
                    e.Graphics.FillRectangle(b, headerRect);&lt;br /&gt;
                }&lt;br /&gt;
                // Draw the title text&lt;br /&gt;
                using (Brush b = new SolidBrush(headerColor))&lt;br /&gt;
                {&lt;br /&gt;
                    e.Graphics.DrawString(_parentForm.Text, _parentForm.Font, b, titleRect);&lt;br /&gt;
                }&lt;br /&gt;
                //Draw the header buttons.&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, miniBoxRect, CaptionButton.Minimize, miniState);&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, maxBoxRect, CaptionButton.Maximize, maxState);&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, closeBoxRect, CaptionButton.Close, closeState);&lt;br /&gt;
                //Draw the border.&lt;br /&gt;
                ControlPaint.DrawBorder(e.Graphics, clientRect, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid);&lt;br /&gt;
            }&lt;br /&gt;
            // Handle resize to adjust the region ot border, header and so on.&lt;br /&gt;
            private void CustomBorderColorForm_Resize(System.Object sender, System.EventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                headerRect = new Rectangle(_parentForm.ClientRectangle.Location, new Size(_parentForm.ClientRectangle.Width, HEADER_HEIGHT));&lt;br /&gt;
                clientRect = new Rectangle(new Point(_parentForm.ClientRectangle.Location.X, _parentForm.ClientRectangle.Y + HEADER_HEIGHT), new Size(_parentForm.ClientRectangle.Width, _parentForm.ClientRectangle.Height - HEADER_HEIGHT));&lt;br /&gt;
                var yOffset = (headerRect.Height + borderWidth - BUTTON_BOX_SIZE.Height) / (double)2;&lt;br /&gt;
                titleRect = new Rectangle((int)yOffset, (int)yOffset, _parentForm.ClientRectangle.Width - 3 * (BUTTON_BOX_SIZE.Width + 1) - (int)yOffset, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                miniBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 3 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                maxBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 2 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                closeBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 1 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                _parentForm.Invalidate();&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Start to move the form.&lt;br /&gt;
                if ((titleRect.Contains(e.Location)))&lt;br /&gt;
                {&lt;br /&gt;
                    x = e.X;&lt;br /&gt;
                    y = e.Y;&lt;br /&gt;
                }&lt;br /&gt;
                // Check and press the header buttons.&lt;br /&gt;
                Point mousePos = _parentForm.PointToClient(Control.MousePosition);&lt;br /&gt;
                if ((miniBoxRect.Contains(mousePos)))&lt;br /&gt;
                    miniState = ButtonState.Pushed;&lt;br /&gt;
                else if ((maxBoxRect.Contains(mousePos)))&lt;br /&gt;
                    maxState = ButtonState.Pushed;&lt;br /&gt;
                else if ((closeBoxRect.Contains(mousePos)))&lt;br /&gt;
                    closeState = ButtonState.Pushed;&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Move and refresh.&lt;br /&gt;
                if ((x != 0 &amp;amp; y != 0))&lt;br /&gt;
                {&lt;br /&gt;
                    _parentForm.Location = new Point(_parentForm.Left + e.X - x, _parentForm.Top + e.Y - y);&lt;br /&gt;
                    _parentForm.Refresh();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Reset the mouse point.&lt;br /&gt;
                x = 0;&lt;br /&gt;
                y = 0;&lt;br /&gt;
                // Check the button states and modify the window state.&lt;br /&gt;
                if (miniState == ButtonState.Pushed)&lt;br /&gt;
                {&lt;br /&gt;
                    _parentForm.WindowState = FormWindowState.Minimized;&lt;br /&gt;
                    miniState = ButtonState.Normal;&lt;br /&gt;
                }&lt;br /&gt;
                else if (maxState == ButtonState.Pushed)&lt;br /&gt;
                {&lt;br /&gt;
                    if (_parentForm.WindowState == FormWindowState.Normal)&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Maximized;&lt;br /&gt;
                        maxState = ButtonState.Checked;&lt;br /&gt;
                    }&lt;br /&gt;
                    else&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Normal;&lt;br /&gt;
                        maxState = ButtonState.Normal;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
                else if (closeState == ButtonState.Pushed)&lt;br /&gt;
                    _parentForm.Close();&lt;br /&gt;
            }&lt;br /&gt;
            // Handle this event to maxmize/normalize the form via double clicking the title bar.&lt;br /&gt;
            private void CustomBorderColorForm_MouseDoubleClick(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                if ((titleRect.Contains(e.Location)))&lt;br /&gt;
                {&lt;br /&gt;
                    if (_parentForm.WindowState == FormWindowState.Normal)&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Maximized;&lt;br /&gt;
                        maxState = ButtonState.Checked;&lt;br /&gt;
                    }&lt;br /&gt;
                    else&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Normal;&lt;br /&gt;
                        maxState = ButtonState.Normal;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
[[File:ColorFramework.png|thumb]]&lt;br /&gt;
    using System.Drawing;&lt;br /&gt;
    using System.Windows.Forms;&lt;br /&gt;
    namespace ColorFramework&lt;br /&gt;
    {&lt;br /&gt;
        public partial class Form1 : Form&lt;br /&gt;
        {&lt;br /&gt;
            ColorSkinBase colorSkinBase;&lt;br /&gt;
            public Form1()&lt;br /&gt;
            {&lt;br /&gt;
                InitializeComponent();&lt;br /&gt;
                colorSkinBase = new ColorSkinBase(this, Color.GreenYellow, Color.Red);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Github ==&lt;br /&gt;
[https://github.com/jholjhapata/ColorFramework Github Link]&lt;br /&gt;
== Problem ==&lt;br /&gt;
This is not exactly the frame of the window, so if we add a panel with 100% width then it may cause issue.&lt;br /&gt;
== Solution ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=ASP.NET_Cookies&amp;diff=138</id>
		<title>ASP.NET Cookies</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=ASP.NET_Cookies&amp;diff=138"/>
		<updated>2020-05-09T17:28:57Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;seo metakeywords=&amp;quot;Cookies,ASP.NET Cookies&amp;quot; metadescription=&amp;quot;Cookies,ASP.NET Cookies&amp;quot;/&amp;gt;&lt;br /&gt;
Cookies is a small piece of information stored on the client machine. Its is used to store user preference information like Password, City, SessionId etc on client machines. We need to import namespace called  Systen.Web before we use cookie(HttpCookie).&lt;br /&gt;
== Type of Cookies ==&lt;br /&gt;
* '''Persistent Cookie''' - Persistent cookies are permanent cookies.They are stored as a text file in the hard disk of the computer.&lt;br /&gt;
* '''Non-Persistent Cookie''' - These cookies are also known as temporary cookies or session based cookies.They are active as long as the browser remains active. Once the browser is closed the cookies vanishes automatically. &lt;br /&gt;
== Create a cookie ==&lt;br /&gt;
In the Asp.Net with help of Response object or HttpCookie we can create a cookie.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
    HttpCookie info = new HttpCookie(&amp;quot;info&amp;quot;);&lt;br /&gt;
    info[&amp;quot;UserFirstName&amp;quot;] = &amp;quot;Soumya&amp;quot;;&lt;br /&gt;
    info[&amp;quot;UserLastName&amp;quot;] = &amp;quot;Das&amp;quot;;&lt;br /&gt;
    info.Expires.Add(new TimeSpan(0, 1, 0));&lt;br /&gt;
    Response.Cookies.Add(info);&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
    Response.Cookies[&amp;quot;UserFirstName&amp;quot;].Value = &amp;quot;Annathurai&amp;quot;;&lt;br /&gt;
    Response.Cookies[&amp;quot;UserLastName&amp;quot;].Value = &amp;quot;Black&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
== Retrieve value from cookie ==&lt;br /&gt;
In the Asp.Net with help of Response object or HttpCookie we can retrieve cookies.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
    string UserFirstName = Request.Cookies[&amp;quot;UserFirstName&amp;quot;].Value;&lt;br /&gt;
    string UserLastName =  Request.Cookies[&amp;quot;UserLastName&amp;quot;].Value;&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
    HttpCookie reqCookies = Request.Cookies[&amp;quot;userInfo&amp;quot;];&lt;br /&gt;
    if (reqCookies != null)&lt;br /&gt;
    {&lt;br /&gt;
        string UserFirstName = reqCookies[&amp;quot;UserFirstName&amp;quot;].ToString();&lt;br /&gt;
        string UserLastName = reqCookies[&amp;quot;UserLastName&amp;quot;].ToString();&lt;br /&gt;
    }&lt;br /&gt;
== Cookie's property ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Property !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Domain || Which is used to associate cookies to domain.&lt;br /&gt;
|-&lt;br /&gt;
| Secure || We can enable secure cookie to set true(HTTPs).&lt;br /&gt;
|-&lt;br /&gt;
| Value || We can manipulate individual cookie.&lt;br /&gt;
|-&lt;br /&gt;
| Values || We can manipulate cookies with key/value pair.&lt;br /&gt;
|-&lt;br /&gt;
| Expires || Which is used to set expire date for the cookies.&lt;br /&gt;
|}&lt;br /&gt;
== Advantages of Cookie ==&lt;br /&gt;
* Its clear text so user can able to read it.&lt;br /&gt;
* We can store user preference information on the client machine.&lt;br /&gt;
* Its easy way to maintain.&lt;br /&gt;
* Fast accessing.&lt;br /&gt;
== Disadvantages of Cookie ==&lt;br /&gt;
* If user clear cookie information we can't get it back.&lt;br /&gt;
* No security.&lt;br /&gt;
* Each request will have cookie information with page.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Open-Closed_Principle&amp;diff=137</id>
		<title>Open-Closed Principle</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Open-Closed_Principle&amp;diff=137"/>
		<updated>2020-05-03T07:54:43Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''open/closed principle''' states &amp;quot;software entities should be open for extension, but closed for modification&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Open for extension means that we should be able to add new features or components to the application without breaking existing code.&lt;br /&gt;
&lt;br /&gt;
Closed for modification means that we should not introduce breaking changes to existing functionality.&lt;br /&gt;
&lt;br /&gt;
== Open-Closed Principle Example ==&lt;br /&gt;
Let’s take a look at an example in C#. Even if you are not a C# developer, with some OOP experience you will be able to follow along easily.&lt;br /&gt;
&lt;br /&gt;
Let’s take a look how to write the below piece of code is violating this principle. &lt;br /&gt;
&lt;br /&gt;
    class Shapes&lt;br /&gt;
    {&lt;br /&gt;
        public Shapes()&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Class : Shapes&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        public void calculateCircleArea(double radius)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Area of circle : &amp;quot; + ((3.14) * radius * radius).ToString());&lt;br /&gt;
        }&lt;br /&gt;
        public void calculateRectangleArea(double length, double width)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Area of rectangle : &amp;quot; + (length * width).ToString());&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
You will notice how we are calculating area of different shapes. If we want to add a new shape then we need to update this class by adding a new method.&lt;br /&gt;
&lt;br /&gt;
This violates the Open-Closed Principle.&lt;br /&gt;
&lt;br /&gt;
Let’s correct it.&lt;br /&gt;
&lt;br /&gt;
    abstract class Shapes&lt;br /&gt;
    {&lt;br /&gt;
        public Shapes()&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Class : Shapes&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        public abstract double calculateArea();&lt;br /&gt;
    }&lt;br /&gt;
    class Square : Shapes&lt;br /&gt;
    {&lt;br /&gt;
        public double length { get; set; }&lt;br /&gt;
        public double width { get; set; }&lt;br /&gt;
        public override double calculateArea()&lt;br /&gt;
        {&lt;br /&gt;
            return (length * width);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class Circle : Shapes&lt;br /&gt;
    {&lt;br /&gt;
        public double radius { get; set; }&lt;br /&gt;
        public override double calculateArea()&lt;br /&gt;
        {&lt;br /&gt;
            return ((3.14) * radius * radius);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
By using '''[[Inheritance]]''' and '''[[Polymorphism]]''', it is now much easier to create extended behavior to the calculate area of different shapes. The cool thing is, that if we want to add new shapes then we can change/add the code without affecting any of these underlying pieces of behavior.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Changing_the_color_of_title_bar_(Non_Client_Area)&amp;diff=136</id>
		<title>Changing the color of title bar (Non Client Area)</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Changing_the_color_of_title_bar_(Non_Client_Area)&amp;diff=136"/>
		<updated>2020-03-29T18:36:17Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Problem ==&lt;br /&gt;
== Solution ==&lt;br /&gt;
== Code ==&lt;br /&gt;
&lt;br /&gt;
    using System.Drawing;&lt;br /&gt;
    using System.Windows.Forms;&lt;br /&gt;
    namespace ColorFramework&lt;br /&gt;
    {&lt;br /&gt;
        public class ColorSkinBase&lt;br /&gt;
        {&lt;br /&gt;
            // A form with custom border and title bar.&lt;br /&gt;
            // Some functions, such as resize the window via mouse, are not implemented yet. &lt;br /&gt;
            // Color color = (Color)ColorConverter.ConvertFromString(&amp;quot;#FFDFD991&amp;quot;);&lt;br /&gt;
            //Color colour = ColorTranslator.FromHtml(&amp;quot;#E7EFF2&amp;quot;);&lt;br /&gt;
            // The color and the width of the border.&lt;br /&gt;
            private Color borderColor;// = Color.GreenYellow;&lt;br /&gt;
            private int borderWidth = 3;&lt;br /&gt;
            // The color and region of the header.&lt;br /&gt;
            private Color headerColor;// = ColorTranslator.FromHtml(&amp;quot;#ff0000&amp;quot;);// Color.Red;&lt;br /&gt;
            private Rectangle headerRect;&lt;br /&gt;
            // The region of the client.&lt;br /&gt;
            private Rectangle clientRect;&lt;br /&gt;
            // The region of the title text.&lt;br /&gt;
            private Rectangle titleRect;&lt;br /&gt;
            // The region of the minimum button.&lt;br /&gt;
            private Rectangle miniBoxRect;&lt;br /&gt;
            // The region of the maximum button.&lt;br /&gt;
            private Rectangle maxBoxRect;&lt;br /&gt;
            // The region of the close button.&lt;br /&gt;
            private Rectangle closeBoxRect;&lt;br /&gt;
            // The states of the three header buttons.&lt;br /&gt;
            private ButtonState miniState;&lt;br /&gt;
            private ButtonState maxState;&lt;br /&gt;
            private ButtonState closeState;&lt;br /&gt;
            // Store the mouse down point to handle moving the form.&lt;br /&gt;
            private int x = 0;&lt;br /&gt;
            private int y = 0;&lt;br /&gt;
            // The height of the header.&lt;br /&gt;
            const int HEADER_HEIGHT = 25;&lt;br /&gt;
            // The size of the header buttons.&lt;br /&gt;
            private readonly Size BUTTON_BOX_SIZE = new Size(15, 15);&lt;br /&gt;
            private System.Windows.Forms.Form _parentForm;&lt;br /&gt;
            public ColorSkinBase(System.Windows.Forms.Form ParentForm, Color borderColor, Color headerColor)&lt;br /&gt;
            {&lt;br /&gt;
                this._parentForm = ParentForm;&lt;br /&gt;
                this.borderColor = borderColor;&lt;br /&gt;
                this.headerColor = headerColor;&lt;br /&gt;
                _parentForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;&lt;br /&gt;
                _parentForm.Paint += new System.Windows.Forms.PaintEventHandler(this.CustomBorderColorForm_Paint);&lt;br /&gt;
                _parentForm.Resize += new System.EventHandler(this.CustomBorderColorForm_Resize);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseDown);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseMove);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseUp);&lt;br /&gt;
                _parentForm.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseDoubleClick);&lt;br /&gt;
            }&lt;br /&gt;
            //private void Form1_Load(System.Object sender, System.EventArgs e)&lt;br /&gt;
            //{&lt;br /&gt;
            //    // Hide the border and the title bar.&lt;br /&gt;
            //    _parentForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;&lt;br /&gt;
            //}&lt;br /&gt;
            private void CustomBorderColorForm_Paint(System.Object sender, System.Windows.Forms.PaintEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Draw the header.&lt;br /&gt;
                using (Brush b = new SolidBrush(borderColor))&lt;br /&gt;
                {&lt;br /&gt;
                    e.Graphics.FillRectangle(b, headerRect);&lt;br /&gt;
                }&lt;br /&gt;
                // Draw the title text&lt;br /&gt;
                using (Brush b = new SolidBrush(headerColor))&lt;br /&gt;
                {&lt;br /&gt;
                    e.Graphics.DrawString(_parentForm.Text, _parentForm.Font, b, titleRect);&lt;br /&gt;
                }&lt;br /&gt;
                //Draw the header buttons.&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, miniBoxRect, CaptionButton.Minimize, miniState);&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, maxBoxRect, CaptionButton.Maximize, maxState);&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, closeBoxRect, CaptionButton.Close, closeState);&lt;br /&gt;
                //Draw the border.&lt;br /&gt;
                ControlPaint.DrawBorder(e.Graphics, clientRect, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid);&lt;br /&gt;
            }&lt;br /&gt;
            // Handle resize to adjust the region ot border, header and so on.&lt;br /&gt;
            private void CustomBorderColorForm_Resize(System.Object sender, System.EventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                headerRect = new Rectangle(_parentForm.ClientRectangle.Location, new Size(_parentForm.ClientRectangle.Width, HEADER_HEIGHT));&lt;br /&gt;
                clientRect = new Rectangle(new Point(_parentForm.ClientRectangle.Location.X, _parentForm.ClientRectangle.Y + HEADER_HEIGHT), new Size(_parentForm.ClientRectangle.Width, _parentForm.ClientRectangle.Height - HEADER_HEIGHT));&lt;br /&gt;
                var yOffset = (headerRect.Height + borderWidth - BUTTON_BOX_SIZE.Height) / (double)2;&lt;br /&gt;
                titleRect = new Rectangle((int)yOffset, (int)yOffset, _parentForm.ClientRectangle.Width - 3 * (BUTTON_BOX_SIZE.Width + 1) - (int)yOffset, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                miniBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 3 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                maxBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 2 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                closeBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 1 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                _parentForm.Invalidate();&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Start to move the form.&lt;br /&gt;
                if ((titleRect.Contains(e.Location)))&lt;br /&gt;
                {&lt;br /&gt;
                    x = e.X;&lt;br /&gt;
                    y = e.Y;&lt;br /&gt;
                }&lt;br /&gt;
                // Check and press the header buttons.&lt;br /&gt;
                Point mousePos = _parentForm.PointToClient(Control.MousePosition);&lt;br /&gt;
                if ((miniBoxRect.Contains(mousePos)))&lt;br /&gt;
                    miniState = ButtonState.Pushed;&lt;br /&gt;
                else if ((maxBoxRect.Contains(mousePos)))&lt;br /&gt;
                    maxState = ButtonState.Pushed;&lt;br /&gt;
                else if ((closeBoxRect.Contains(mousePos)))&lt;br /&gt;
                    closeState = ButtonState.Pushed;&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Move and refresh.&lt;br /&gt;
                if ((x != 0 &amp;amp; y != 0))&lt;br /&gt;
                {&lt;br /&gt;
                    _parentForm.Location = new Point(_parentForm.Left + e.X - x, _parentForm.Top + e.Y - y);&lt;br /&gt;
                    _parentForm.Refresh();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Reset the mouse point.&lt;br /&gt;
                x = 0;&lt;br /&gt;
                y = 0;&lt;br /&gt;
                // Check the button states and modify the window state.&lt;br /&gt;
                if (miniState == ButtonState.Pushed)&lt;br /&gt;
                {&lt;br /&gt;
                    _parentForm.WindowState = FormWindowState.Minimized;&lt;br /&gt;
                    miniState = ButtonState.Normal;&lt;br /&gt;
                }&lt;br /&gt;
                else if (maxState == ButtonState.Pushed)&lt;br /&gt;
                {&lt;br /&gt;
                    if (_parentForm.WindowState == FormWindowState.Normal)&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Maximized;&lt;br /&gt;
                        maxState = ButtonState.Checked;&lt;br /&gt;
                    }&lt;br /&gt;
                    else&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Normal;&lt;br /&gt;
                        maxState = ButtonState.Normal;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
                else if (closeState == ButtonState.Pushed)&lt;br /&gt;
                    _parentForm.Close();&lt;br /&gt;
            }&lt;br /&gt;
            // Handle this event to maxmize/normalize the form via double clicking the title bar.&lt;br /&gt;
            private void CustomBorderColorForm_MouseDoubleClick(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                if ((titleRect.Contains(e.Location)))&lt;br /&gt;
                {&lt;br /&gt;
                    if (_parentForm.WindowState == FormWindowState.Normal)&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Maximized;&lt;br /&gt;
                        maxState = ButtonState.Checked;&lt;br /&gt;
                    }&lt;br /&gt;
                    else&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Normal;&lt;br /&gt;
                        maxState = ButtonState.Normal;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
[[File:ColorFramework.png|thumb]]&lt;br /&gt;
    using System.Drawing;&lt;br /&gt;
    using System.Windows.Forms;&lt;br /&gt;
    namespace ColorFramework&lt;br /&gt;
    {&lt;br /&gt;
        public partial class Form1 : Form&lt;br /&gt;
        {&lt;br /&gt;
            ColorSkinBase colorSkinBase;&lt;br /&gt;
            public Form1()&lt;br /&gt;
            {&lt;br /&gt;
                InitializeComponent();&lt;br /&gt;
                colorSkinBase = new ColorSkinBase(this, Color.GreenYellow, Color.Red);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Github ==&lt;br /&gt;
[https://github.com/jholjhapata/ColorFramework Github Link]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=File:ColorFramework.png&amp;diff=135</id>
		<title>File:ColorFramework.png</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=File:ColorFramework.png&amp;diff=135"/>
		<updated>2020-03-29T08:55:58Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ColorFramework output example&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Changing_the_color_of_title_bar_(Non_Client_Area)&amp;diff=134</id>
		<title>Changing the color of title bar (Non Client Area)</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Changing_the_color_of_title_bar_(Non_Client_Area)&amp;diff=134"/>
		<updated>2020-03-28T18:21:15Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;== Problem == == Solution == == Code ==     using System;     using System.Collections.Generic;     using System.Drawing;     using System.Linq;     using System.Text;     usi...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Problem ==&lt;br /&gt;
== Solution ==&lt;br /&gt;
== Code ==&lt;br /&gt;
    using System;&lt;br /&gt;
    using System.Collections.Generic;&lt;br /&gt;
    using System.Drawing;&lt;br /&gt;
    using System.Linq;&lt;br /&gt;
    using System.Text;&lt;br /&gt;
    using System.Threading.Tasks;&lt;br /&gt;
    using System.Windows.Forms;&lt;br /&gt;
    namespace ColorFramework&lt;br /&gt;
    {&lt;br /&gt;
        public class ColorSkinBase&lt;br /&gt;
        {&lt;br /&gt;
            // A form with custom border and title bar.&lt;br /&gt;
            // Some functions, such as resize the window via mouse, are not implemented yet. &lt;br /&gt;
            // Color color = (Color)ColorConverter.ConvertFromString(&amp;quot;#FFDFD991&amp;quot;);&lt;br /&gt;
            //Color colour = ColorTranslator.FromHtml(&amp;quot;#E7EFF2&amp;quot;);&lt;br /&gt;
            // The color and the width of the border.&lt;br /&gt;
            private Color borderColor;// = Color.GreenYellow;&lt;br /&gt;
            private int borderWidth = 3;&lt;br /&gt;
            // The color and region of the header.&lt;br /&gt;
            private Color headerColor;// = ColorTranslator.FromHtml(&amp;quot;#ff0000&amp;quot;);// Color.Red;&lt;br /&gt;
            private Rectangle headerRect;&lt;br /&gt;
            // The region of the client.&lt;br /&gt;
            private Rectangle clientRect;&lt;br /&gt;
            // The region of the title text.&lt;br /&gt;
            private Rectangle titleRect;&lt;br /&gt;
            // The region of the minimum button.&lt;br /&gt;
            private Rectangle miniBoxRect;&lt;br /&gt;
            // The region of the maximum button.&lt;br /&gt;
            private Rectangle maxBoxRect;&lt;br /&gt;
            // The region of the close button.&lt;br /&gt;
            private Rectangle closeBoxRect;&lt;br /&gt;
            // The states of the three header buttons.&lt;br /&gt;
            private ButtonState miniState;&lt;br /&gt;
            private ButtonState maxState;&lt;br /&gt;
            private ButtonState closeState;&lt;br /&gt;
            // Store the mouse down point to handle moving the form.&lt;br /&gt;
            private int x = 0;&lt;br /&gt;
            private int y = 0;&lt;br /&gt;
            // The height of the header.&lt;br /&gt;
            const int HEADER_HEIGHT = 25;&lt;br /&gt;
            // The size of the header buttons.&lt;br /&gt;
            private readonly Size BUTTON_BOX_SIZE = new Size(15, 15);&lt;br /&gt;
            private System.Windows.Forms.Form _parentForm;&lt;br /&gt;
            public ColorSkinBase(System.Windows.Forms.Form ParentForm, Color borderColor, Color headerColor)&lt;br /&gt;
            {&lt;br /&gt;
                this._parentForm = ParentForm;&lt;br /&gt;
                this.borderColor = borderColor;&lt;br /&gt;
                this.headerColor = headerColor;&lt;br /&gt;
                _parentForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;&lt;br /&gt;
                _parentForm.Paint += new System.Windows.Forms.PaintEventHandler(this.CustomBorderColorForm_Paint);&lt;br /&gt;
                _parentForm.Resize += new System.EventHandler(this.CustomBorderColorForm_Resize);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseDown);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseMove);&lt;br /&gt;
                _parentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseUp);&lt;br /&gt;
                _parentForm.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.CustomBorderColorForm_MouseDoubleClick);&lt;br /&gt;
            }&lt;br /&gt;
            //private void Form1_Load(System.Object sender, System.EventArgs e)&lt;br /&gt;
            //{&lt;br /&gt;
            //    // Hide the border and the title bar.&lt;br /&gt;
            //    _parentForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;&lt;br /&gt;
            //}&lt;br /&gt;
            private void CustomBorderColorForm_Paint(System.Object sender, System.Windows.Forms.PaintEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Draw the header.&lt;br /&gt;
                using (Brush b = new SolidBrush(borderColor))&lt;br /&gt;
                {&lt;br /&gt;
                    e.Graphics.FillRectangle(b, headerRect);&lt;br /&gt;
                }&lt;br /&gt;
                // Draw the title text&lt;br /&gt;
                using (Brush b = new SolidBrush(headerColor))&lt;br /&gt;
                {&lt;br /&gt;
                    e.Graphics.DrawString(_parentForm.Text, _parentForm.Font, b, titleRect);&lt;br /&gt;
                }&lt;br /&gt;
                //Draw the header buttons.&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, miniBoxRect, CaptionButton.Minimize, miniState);&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, maxBoxRect, CaptionButton.Maximize, maxState);&lt;br /&gt;
                if (_parentForm.MinimizeBox)&lt;br /&gt;
                    ControlPaint.DrawCaptionButton(e.Graphics, closeBoxRect, CaptionButton.Close, closeState);&lt;br /&gt;
                //Draw the border.&lt;br /&gt;
                ControlPaint.DrawBorder(e.Graphics, clientRect, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid);&lt;br /&gt;
            }&lt;br /&gt;
            // Handle resize to adjust the region ot border, header and so on.&lt;br /&gt;
            private void CustomBorderColorForm_Resize(System.Object sender, System.EventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                headerRect = new Rectangle(_parentForm.ClientRectangle.Location, new Size(_parentForm.ClientRectangle.Width, HEADER_HEIGHT));&lt;br /&gt;
                clientRect = new Rectangle(new Point(_parentForm.ClientRectangle.Location.X, _parentForm.ClientRectangle.Y + HEADER_HEIGHT), new Size(_parentForm.ClientRectangle.Width, _parentForm.ClientRectangle.Height - HEADER_HEIGHT));&lt;br /&gt;
                var yOffset = (headerRect.Height + borderWidth - BUTTON_BOX_SIZE.Height) / (double)2;&lt;br /&gt;
                titleRect = new Rectangle((int)yOffset, (int)yOffset, _parentForm.ClientRectangle.Width - 3 * (BUTTON_BOX_SIZE.Width + 1) - (int)yOffset, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                miniBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 3 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                maxBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 2 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                closeBoxRect = new Rectangle(_parentForm.ClientRectangle.Width - 1 * (BUTTON_BOX_SIZE.Width + 1), (int)yOffset, BUTTON_BOX_SIZE.Width, BUTTON_BOX_SIZE.Height);&lt;br /&gt;
                _parentForm.Invalidate();&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Start to move the form.&lt;br /&gt;
                if ((titleRect.Contains(e.Location)))&lt;br /&gt;
                {&lt;br /&gt;
                    x = e.X;&lt;br /&gt;
                    y = e.Y;&lt;br /&gt;
                }&lt;br /&gt;
                // Check and press the header buttons.&lt;br /&gt;
                Point mousePos = _parentForm.PointToClient(Control.MousePosition);&lt;br /&gt;
                if ((miniBoxRect.Contains(mousePos)))&lt;br /&gt;
                    miniState = ButtonState.Pushed;&lt;br /&gt;
                else if ((maxBoxRect.Contains(mousePos)))&lt;br /&gt;
                    maxState = ButtonState.Pushed;&lt;br /&gt;
                else if ((closeBoxRect.Contains(mousePos)))&lt;br /&gt;
                    closeState = ButtonState.Pushed;&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Move and refresh.&lt;br /&gt;
                if ((x != 0 &amp;amp; y != 0))&lt;br /&gt;
                {&lt;br /&gt;
                    _parentForm.Location = new Point(_parentForm.Left + e.X - x, _parentForm.Top + e.Y - y);&lt;br /&gt;
                    _parentForm.Refresh();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            private void CustomBorderColorForm_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                // Reset the mouse point.&lt;br /&gt;
                x = 0;&lt;br /&gt;
                y = 0;&lt;br /&gt;
                // Check the button states and modify the window state.&lt;br /&gt;
                if (miniState == ButtonState.Pushed)&lt;br /&gt;
                {&lt;br /&gt;
                    _parentForm.WindowState = FormWindowState.Minimized;&lt;br /&gt;
                    miniState = ButtonState.Normal;&lt;br /&gt;
                }&lt;br /&gt;
                else if (maxState == ButtonState.Pushed)&lt;br /&gt;
                {&lt;br /&gt;
                    if (_parentForm.WindowState == FormWindowState.Normal)&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Maximized;&lt;br /&gt;
                        maxState = ButtonState.Checked;&lt;br /&gt;
                    }&lt;br /&gt;
                    else&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Normal;&lt;br /&gt;
                        maxState = ButtonState.Normal;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
                else if (closeState == ButtonState.Pushed)&lt;br /&gt;
                    _parentForm.Close();&lt;br /&gt;
            }&lt;br /&gt;
            // Handle this event to maxmize/normalize the form via double clicking the title bar.&lt;br /&gt;
            private void CustomBorderColorForm_MouseDoubleClick(System.Object sender, System.Windows.Forms.MouseEventArgs e)&lt;br /&gt;
            {&lt;br /&gt;
                if ((titleRect.Contains(e.Location)))&lt;br /&gt;
                {&lt;br /&gt;
                    if (_parentForm.WindowState == FormWindowState.Normal)&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Maximized;&lt;br /&gt;
                        maxState = ButtonState.Checked;&lt;br /&gt;
                    }&lt;br /&gt;
                    else&lt;br /&gt;
                    {&lt;br /&gt;
                        _parentForm.WindowState = FormWindowState.Normal;&lt;br /&gt;
                        maxState = ButtonState.Normal;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Download DLL ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Factory_Method_Design_Pattern&amp;diff=133</id>
		<title>Factory Method Design Pattern</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Factory_Method_Design_Pattern&amp;diff=133"/>
		<updated>2020-02-23T13:52:04Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Factory Method Design Pattern.png|thumb|Factory Method Design Pattern]]&lt;br /&gt;
Factory Pattern or Factory Method Pattern is a creational design pattern that provides an interface or abstract class for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created. In other words, subclasses are responsible to create the instance of the class.&lt;br /&gt;
== Business Requirement Example ==&lt;br /&gt;
* We need two types of employee permanent and contract.&lt;br /&gt;
* Contract employee's Salary is 80000 and Bonus is 1000.&lt;br /&gt;
* Permanent employee's Salary is 50000 and Bonus is 5000.&lt;br /&gt;
* Contract employee has medical allowance of 2000. '''Only for Contract employee'''.&lt;br /&gt;
* Permanent employee has house allowance of 5000. '''Only for Permanent employee'''.&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    public interface IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        void setSalary();&lt;br /&gt;
        void setBonus();&lt;br /&gt;
    }&lt;br /&gt;
    class PermanentEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 5000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 50000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setHouseAllowance()&lt;br /&gt;
        {&lt;br /&gt;
            Salary += 5000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ContractEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 1000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 80000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setMedicalAllowance()&lt;br /&gt;
        {&lt;br /&gt;
            Salary += 2000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public IEmployee GetEmployee(string name, EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            IEmployee _employee= null;&lt;br /&gt;
            if (employeeType.Id == 1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new PermanentEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            else if (employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new ContractEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 2,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeFactory employeeFactory = new EmployeeFactory();&lt;br /&gt;
            IEmployee _contractEmplyee = employeeFactory.GetEmployee(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            _contractEmplyee.setBonus();&lt;br /&gt;
            _contractEmplyee.setSalary();&lt;br /&gt;
            IEmployee _permanentEmplyee = employeeFactory.GetEmployee(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
            _permanentEmplyee.setBonus();&lt;br /&gt;
            _permanentEmplyee.setSalary();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Problem ==&lt;br /&gt;
If we need to compute the house allowance specific to Permanent employee and medical allowance specific to Contract employee then [[Simple Factory Pattern]] will be difficult as we can not call setHouseAllowance() or setMedicalAllowance() function on the Main() function and our '''EmployeeFactory''' class have to take-care of the computation based on the instance of the object. &lt;br /&gt;
&lt;br /&gt;
This approach violates the [[SOLID Principles]].&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
We have to created PermanentEmployeeFactory and ContractEmployeeFactory which will calculate the house allowance specific to Permanent employee and medical allowance specific to Contract employee. And the common function setBonus() and setSalary() will be executed by BaseEmployeeFactory class.&lt;br /&gt;
&lt;br /&gt;
In EmployeeFactory we will call ApplySalary() function, which will create an instance of my object and do all the calculation.&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    class Employee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public int HouseAllowance { get; set; }&lt;br /&gt;
        public int MedicalAllowance { get; set; }&lt;br /&gt;
    }&lt;br /&gt;
    public interface IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        void setSalary();&lt;br /&gt;
        void setBonus();&lt;br /&gt;
    }&lt;br /&gt;
    class PermanentEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        Employee employee = new Employee();&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            employee.Bonus = 5000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            employee.Salary = 50000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setHouseAllowance()&lt;br /&gt;
        {&lt;br /&gt;
            employee.HouseAllowance = 5000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ContractEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        Employee employee = new Employee();&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            employee.Bonus = 1000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            employee.Salary = 80000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setMedicalAllowance()&lt;br /&gt;
        {&lt;br /&gt;
            employee.MedicalAllowance = 2000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    abstract class BaseEmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public IEmployee ApplySalary()&lt;br /&gt;
        {&lt;br /&gt;
            IEmployee emp = this.Create();&lt;br /&gt;
            emp.setBonus();&lt;br /&gt;
            emp.setSalary();&lt;br /&gt;
            return emp;&lt;br /&gt;
        }&lt;br /&gt;
        public abstract IEmployee Create();&lt;br /&gt;
    }&lt;br /&gt;
    class PermanentEmployeeFactory : BaseEmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public override IEmployee Create()&lt;br /&gt;
        {&lt;br /&gt;
            PermanentEmployee permanentEmployee = new PermanentEmployee();&lt;br /&gt;
            permanentEmployee.setHouseAllowance();&lt;br /&gt;
            return permanentEmployee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ContractEmployeeFactory : BaseEmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public override IEmployee Create()&lt;br /&gt;
        {&lt;br /&gt;
            ContractEmployee contractEmployee = new ContractEmployee();&lt;br /&gt;
            contractEmployee.setMedicalAllowance();&lt;br /&gt;
            return contractEmployee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public IEmployee GetEmployee(string name, EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            BaseEmployeeFactory _employeeFactory = null;&lt;br /&gt;
            if (employeeType.Id == 1)&lt;br /&gt;
            {&lt;br /&gt;
                _employeeFactory = new PermanentEmployeeFactory();&lt;br /&gt;
            }&lt;br /&gt;
            else if (employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employeeFactory = new ContractEmployeeFactory();&lt;br /&gt;
            }&lt;br /&gt;
            return _employeeFactory.ApplySalary();&lt;br /&gt;
            //return _employeeFactory;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&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;
           var obj = FactoryMethodDesignPattern();&lt;br /&gt;
        }&lt;br /&gt;
        static List&amp;lt;IEmployee&amp;gt; FactoryMethodDesignPattern()&lt;br /&gt;
        {&lt;br /&gt;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 2,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeFactory employeeFactory = new EmployeeFactory();&lt;br /&gt;
            IEmployee _contractEmplyee = employeeFactory.GetEmployee(&amp;quot;Jhon&amp;quot;, _contractEmplyeeType);            &lt;br /&gt;
            IEmployee _permanentEmplyee = employeeFactory.GetEmployee(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
            List&amp;lt;IEmployee&amp;gt; listObj = new List&amp;lt;IEmployee&amp;gt;();&lt;br /&gt;
            listObj.Add(_contractEmplyee);&lt;br /&gt;
            listObj.Add(_permanentEmplyee);&lt;br /&gt;
            return listObj;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Advantage of Factory Method Design Pattern ==&lt;br /&gt;
* Allows you to hide implementation of an application seam (the core interfaces that make up your application)&lt;br /&gt;
* Allows you to easily test the seam of an application (that is to mock/stub) certain parts of your application so you can build and test the other parts&lt;br /&gt;
* Allows you to change the design of your application more readily, this is known as loose coupling.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=132</id>
		<title>Simple Factory Pattern</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=132"/>
		<updated>2020-02-23T13:03:00Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple Factory Pattern returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and common methods, but each may perform a task differently or optimize for different data or behaviors.&lt;br /&gt;
&lt;br /&gt;
The classes in Simple Factory Pattern will have the same parent class and methods but will perform the task differently dependent of the type of data supplied.&lt;br /&gt;
&lt;br /&gt;
Let's take a look at the diagram to get a high-level view of how the Simple Factory Pattern works in C#.&lt;br /&gt;
[[File:Simple Factory Pattern Diagram.png|Simple Factory Pattern]]&lt;br /&gt;
[[File:Simple Factory Pattern.png|Simple Factory Pattern]]&lt;br /&gt;
&lt;br /&gt;
In the diagram Manufacture is a base class, and classes Permanent Employee and Contract Employee are derived from it, the Manufacture class decides which of the subclasses to return, depending on the arguments provided.&lt;br /&gt;
&lt;br /&gt;
The developer using the Manufacture class doesn’t really care which of the subclasses is returned, because each of them have the same methods but will have different implementations. How the factory class(Manufacture class) decides which one to return, is entirely up to what data is supplied.&lt;br /&gt;
== Business Requirement Example ==&lt;br /&gt;
* We need two types of employee permanent and contract.&lt;br /&gt;
* Contract employee's Salary is 80000 and Bonus is 1000.&lt;br /&gt;
* Permanent employee's Salary is 50000 and Bonus is 5000.&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
    }&lt;br /&gt;
    class Employees&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 2,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            Employees _contractEmplyee = create(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            Employees _permanentEmplyee = create(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
        }&lt;br /&gt;
        static Employees create(string name,EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            Employees _employee = new Employees();&lt;br /&gt;
            if(employeeType.Id==1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee.Salary = 50000;&lt;br /&gt;
                _employee.Bonus = 5000;&lt;br /&gt;
            }&lt;br /&gt;
            else if(employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee.Salary = 80000;&lt;br /&gt;
                _employee.Bonus = 1000;&lt;br /&gt;
            }&lt;br /&gt;
            _employee.EmployeeType = employeeType;&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Problem ==&lt;br /&gt;
The above solves our business requirement but we have some drawbacks..&lt;br /&gt;
* Tightly coupled business logic.&lt;br /&gt;
* Need more development and testing effort when any changes required because we need to update the create() function every-time.&lt;br /&gt;
* Violating [[Single Responsibility Principle]] as '''Main''' function/class is responsible for object creation and payment declaration.&lt;br /&gt;
* Violating [[Open-Closed Principle|Open-Closed-principle]] as we need to change the main function/class every time when we need a new type of employee.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
Let's take a look at the below solution:&lt;br /&gt;
* We have decoupled Employee by using '''IEmployee''' interface. &lt;br /&gt;
* '''EmployeeFactory''' is responsible for object creation. &lt;br /&gt;
* '''Main''' function/class not responsible for object creation, so we don't have to change it when there is an update in salary/bonus or we have a new type of employee. &lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    public interface IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        void setSalary();&lt;br /&gt;
        void setBonus();&lt;br /&gt;
    }&lt;br /&gt;
    class PermanentEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 5000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 50000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ContractEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 1000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 80000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public IEmployee GetEmployee(string name, EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            IEmployee _employee= null;&lt;br /&gt;
            if (employeeType.Id == 1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new PermanentEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            else if (employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new ContractEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 2,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeFactory employeeFactory = new EmployeeFactory();&lt;br /&gt;
            IEmployee _contractEmplyee = employeeFactory.GetEmployee(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            _contractEmplyee.setBonus();&lt;br /&gt;
            _contractEmplyee.setSalary();&lt;br /&gt;
            IEmployee _permanentEmplyee = employeeFactory.GetEmployee(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
            _permanentEmplyee.setBonus();&lt;br /&gt;
            _permanentEmplyee.setSalary();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Advantage of Simple Factory Pattern ==&lt;br /&gt;
This follows the [[Open-Closed Principle|Open-Closed-principle]]: Our Employee class is closed, as we have a fixed set of Employee, which we hire, but we are open for new Employees.&lt;br /&gt;
&lt;br /&gt;
Further: Each new Employee have their set of functions. The Permanent Employee  doesn't care what/how to do a Contract Employee ([[Single Responsibility Principle]]).&lt;br /&gt;
&lt;br /&gt;
Last but not least, we decoupled different Employee types from the Main function. The main function needs only to know how to handle.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Factory_Method_Design_Pattern&amp;diff=131</id>
		<title>Factory Method Design Pattern</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Factory_Method_Design_Pattern&amp;diff=131"/>
		<updated>2020-02-23T11:25:19Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Factory Method Design Pattern.png|thumb|Factory Method Design Pattern]]&lt;br /&gt;
Factory Pattern or Factory Method Pattern is a creational design pattern that provides an interface or abstract class for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created. In other words, subclasses are responsible to create the instance of the class.&lt;br /&gt;
== Business Requirement Example ==&lt;br /&gt;
* We need two types of employee permanent and contract.&lt;br /&gt;
* Contract employee's Salary is 80000 and Bonus is 1000.&lt;br /&gt;
* Permanent employee's Salary is 50000 and Bonus is 5000.&lt;br /&gt;
* Contract employee has medical allowance of 2000. '''Only for Contract employee'''.&lt;br /&gt;
* Permanent employee has hose allowance of 5000. '''Only for Permanent employee'''.&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    public interface IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        void setSalary();&lt;br /&gt;
        void setBonus();&lt;br /&gt;
    }&lt;br /&gt;
    class PermanentEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 5000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 50000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setHoseAllowance()&lt;br /&gt;
        {&lt;br /&gt;
            Salary += 5000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ContractEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 1000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 80000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setMedicalAllowance()&lt;br /&gt;
        {&lt;br /&gt;
            Salary += 2000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public IEmployee GetEmployee(string name, EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            IEmployee _employee= null;&lt;br /&gt;
            if (employeeType.Id == 1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new PermanentEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            else if (employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new ContractEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeFactory employeeFactory = new EmployeeFactory();&lt;br /&gt;
            IEmployee _contractEmplyee = employeeFactory.GetEmployee(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            _contractEmplyee.setBonus();&lt;br /&gt;
            _contractEmplyee.setSalary();&lt;br /&gt;
            IEmployee _permanentEmplyee = employeeFactory.GetEmployee(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
            _permanentEmplyee.setBonus();&lt;br /&gt;
            _permanentEmplyee.setSalary();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Problem ==&lt;br /&gt;
If we need to compute the hose allowance specific to Permanent employee and medical allowance specific to Contract employee then [[Simple Factory Pattern]] will be difficult as we can not call setHoseAllowance() or setMedicalAllowance() function on the Main() function and our '''EmployeeFactory''' class have to take-care of the computation based on the instance of the object. &lt;br /&gt;
&lt;br /&gt;
This approach violates the [[SOLID Principles]].&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
== Advantage of Factory Method Design Pattern ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=130</id>
		<title>Simple Factory Pattern</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=130"/>
		<updated>2020-02-23T10:44:52Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple Factory Pattern returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and common methods, but each may perform a task differently or optimize for different data or behaviors.&lt;br /&gt;
&lt;br /&gt;
The classes in Simple Factory Pattern will have the same parent class and methods but will perform the task differently dependent of the type of data supplied.&lt;br /&gt;
&lt;br /&gt;
Let's take a look at the diagram to get a high-level view of how the Simple Factory Pattern works in C#.&lt;br /&gt;
[[File:Simple Factory Pattern Diagram.png|Simple Factory Pattern]]&lt;br /&gt;
[[File:Simple Factory Pattern.png|Simple Factory Pattern]]&lt;br /&gt;
&lt;br /&gt;
In the diagram Manufacture is a base class, and classes Permanent Employee and Contract Employee are derived from it, the Manufacture class decides which of the subclasses to return, depending on the arguments provided.&lt;br /&gt;
&lt;br /&gt;
The developer using the Manufacture class doesn’t really care which of the subclasses is returned, because each of them have the same methods but will have different implementations. How the factory class(Manufacture class) decides which one to return, is entirely up to what data is supplied.&lt;br /&gt;
== Business Requirement Example ==&lt;br /&gt;
* We need two types of employee permanent and contract.&lt;br /&gt;
* Contract employee's Salary is 80000 and Bonus is 1000.&lt;br /&gt;
* Permanent employee's Salary is 50000 and Bonus is 5000.&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
    }&lt;br /&gt;
    class Employees&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 2,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            Employees _contractEmplyee = create(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            Employees _permanentEmplyee = create(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
        }&lt;br /&gt;
        static Employees create(string name,EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            Employees _employee = new Employees();&lt;br /&gt;
            if(employeeType.Id==1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee.Salary = 50000;&lt;br /&gt;
                _employee.Bonus = 5000;&lt;br /&gt;
            }&lt;br /&gt;
            else if(employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee.Salary = 80000;&lt;br /&gt;
                _employee.Bonus = 1000;&lt;br /&gt;
            }&lt;br /&gt;
            _employee.EmployeeType = employeeType;&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Problem ==&lt;br /&gt;
The above solves our business requirement but we have some drawbacks..&lt;br /&gt;
* Tightly coupled business logic.&lt;br /&gt;
* Need more development and testing effort when any changes required because we need to update the create() function every-time.&lt;br /&gt;
* Violating [[Single Responsibility Principle]] as '''Main''' function/class is responsible for object creation and payment declaration.&lt;br /&gt;
* Violating [[Open-Closed Principle|Open-Closed-principle]] as we need to change the main function/class every time when we need a new type of employee.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
Let's take a look at the below solution:&lt;br /&gt;
* We have decoupled Employee by using '''IEmployee''' interface. &lt;br /&gt;
* '''EmployeeFactory''' is responsible for object creation. &lt;br /&gt;
* '''Main''' function/class not responsible for object creation, so we don't have to change it when there is an update in salary/bonus or we have a new type of employee. &lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    public interface IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        void setSalary();&lt;br /&gt;
        void setBonus();&lt;br /&gt;
    }&lt;br /&gt;
    class PermanentEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 5000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 50000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ContractEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 1000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 80000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public IEmployee GetEmployee(string name, EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            IEmployee _employee= null;&lt;br /&gt;
            if (employeeType.Id == 1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new PermanentEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            else if (employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new ContractEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeFactory employeeFactory = new EmployeeFactory();&lt;br /&gt;
            IEmployee _contractEmplyee = employeeFactory.GetEmployee(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            _contractEmplyee.setBonus();&lt;br /&gt;
            _contractEmplyee.setSalary();&lt;br /&gt;
            IEmployee _permanentEmplyee = employeeFactory.GetEmployee(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
            _permanentEmplyee.setBonus();&lt;br /&gt;
            _permanentEmplyee.setSalary();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Advantage of Simple Factory Pattern ==&lt;br /&gt;
This follows the [[Open-Closed Principle|Open-Closed-principle]]: Our Employee class is closed, as we have a fixed set of Employee, which we hire, but we are open for new Employees.&lt;br /&gt;
&lt;br /&gt;
Further: Each new Employee have their set of functions. The Permanent Employee  doesn't care what/how to do a Contract Employee ([[Single Responsibility Principle]]).&lt;br /&gt;
&lt;br /&gt;
Last but not least, we decoupled different Employee types from the Main function. The main function needs only to know how to handle.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=File:Factory_Method_Design_Pattern.png&amp;diff=129</id>
		<title>File:Factory Method Design Pattern.png</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=File:Factory_Method_Design_Pattern.png&amp;diff=129"/>
		<updated>2020-02-23T10:43:20Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Factory Method Design Pattern&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=128</id>
		<title>Simple Factory Pattern</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=128"/>
		<updated>2020-02-23T10:36:06Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple Factory Pattern returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and common methods, but each may perform a task differently or optimize for different data or behaviors.&lt;br /&gt;
&lt;br /&gt;
The classes in Simple Factory Pattern will have the same parent class and methods but will perform the task differently dependent of the type of data supplied.&lt;br /&gt;
&lt;br /&gt;
Let's take a look at the diagram to get a high-level view of how the Simple Factory Pattern works in C#.&lt;br /&gt;
[[File:Simple Factory Pattern Diagram.png|Simple Factory Pattern]]&lt;br /&gt;
[[File:Simple Factory Pattern.png|Simple Factory Pattern]]&lt;br /&gt;
&lt;br /&gt;
In the diagram Manufacture is a base class, and classes Permanent Employee and Contract Employee are derived from it, the Manufacture class decides which of the subclasses to return, depending on the arguments provided.&lt;br /&gt;
&lt;br /&gt;
The developer using the Manufacture class doesn’t really care which of the subclasses is returned, because each of them have the same methods but will have different implementations. How the factory class(Manufacture class) decides which one to return, is entirely up to what data is supplied.&lt;br /&gt;
== Business Requirement Example ==&lt;br /&gt;
* We need two types of employee permanent and contract.&lt;br /&gt;
* Contract employee's Salary is 80000 and Bonus is 0.&lt;br /&gt;
* Permanent employee's Salary is 50000 and Bonus is 5000.&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
    }&lt;br /&gt;
    class Employees&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 2,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            Employees _contractEmplyee = create(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            Employees _permanentEmplyee = create(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
        }&lt;br /&gt;
        static Employees create(string name,EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            Employees _employee = new Employees();&lt;br /&gt;
            if(employeeType.Id==1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee.Salary = 50000;&lt;br /&gt;
                _employee.Bonus = 5000;&lt;br /&gt;
            }&lt;br /&gt;
            else if(employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee.Salary = 80000;&lt;br /&gt;
                _employee.Bonus = 0;&lt;br /&gt;
            }&lt;br /&gt;
            _employee.EmployeeType = employeeType;&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Problem ==&lt;br /&gt;
The above solves our business requirement but we have some drawbacks..&lt;br /&gt;
* Tightly coupled business logic.&lt;br /&gt;
* Need more development and testing effort when any changes required because we need to update the create() function every-time.&lt;br /&gt;
* Violating [[Single Responsibility Principle]] as '''Main''' function/class is responsible for object creation and payment declaration.&lt;br /&gt;
* Violating [[Open-Closed Principle|Open-Closed-principle]] as we need to change the main function/class every time when we need a new type of employee.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
Let's take a look at the below solution:&lt;br /&gt;
* We have decoupled Employee by using '''IEmployee''' interface. &lt;br /&gt;
* '''EmployeeFactory''' is responsible for object creation. &lt;br /&gt;
* '''Main''' function/class not responsible for object creation, so we don't have to change it when there is an update in salary/bonus or we have a new type of employee. &lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    public interface IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        void setSalary();&lt;br /&gt;
        void setBonus();&lt;br /&gt;
    }&lt;br /&gt;
    class PermanentEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 5000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 50000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ContractEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 0;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 80000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public IEmployee GetEmployee(string name, EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            IEmployee _employee= null;&lt;br /&gt;
            if (employeeType.Id == 1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new PermanentEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            else if (employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new ContractEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeFactory employeeFactory = new EmployeeFactory();&lt;br /&gt;
            IEmployee _contractEmplyee = employeeFactory.GetEmployee(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            _contractEmplyee.setBonus();&lt;br /&gt;
            _contractEmplyee.setSalary();&lt;br /&gt;
            IEmployee _permanentEmplyee = employeeFactory.GetEmployee(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
            _permanentEmplyee.setBonus();&lt;br /&gt;
            _permanentEmplyee.setSalary();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Advantage of Simple Factory Pattern ==&lt;br /&gt;
This follows the [[Open-Closed Principle|Open-Closed-principle]]: Our Employee class is closed, as we have a fixed set of Employee, which we hire, but we are open for new Employees.&lt;br /&gt;
&lt;br /&gt;
Further: Each new Employee have their set of functions. The Permanent Employee  doesn't care what/how to do a Contract Employee ([[Single Responsibility Principle]]).&lt;br /&gt;
&lt;br /&gt;
Last but not least, we decoupled different Employee types from the Main function. The main function needs only to know how to handle.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=File:Simple_Factory_Pattern_Diagram.png&amp;diff=127</id>
		<title>File:Simple Factory Pattern Diagram.png</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=File:Simple_Factory_Pattern_Diagram.png&amp;diff=127"/>
		<updated>2020-02-23T10:35:45Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple Factory Pattern&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=126</id>
		<title>Simple Factory Pattern</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=126"/>
		<updated>2020-02-23T10:01:04Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple Factory Pattern returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and common methods, but each may perform a task differently or optimize for different data or behaviors.&lt;br /&gt;
&lt;br /&gt;
The classes in Simple Factory Pattern will have the same parent class and methods but will perform the task differently dependent of the type of data supplied.&lt;br /&gt;
&lt;br /&gt;
Let's take a look at the diagram to get a high-level view of how the Simple Factory Pattern works in C#.&lt;br /&gt;
[[File:Simple Factory Pattern.png|Simple Factory Pattern]]&lt;br /&gt;
&lt;br /&gt;
In the diagram Manufacture is a base class, and classes Permanent Employee and Contract Employee are derived from it, the Manufacture class decides which of the subclasses to return, depending on the arguments provided.&lt;br /&gt;
&lt;br /&gt;
The developer using the Manufacture class doesn’t really care which of the subclasses is returned, because each of them have the same methods but will have different implementations. How the factory class(Manufacture class) decides which one to return, is entirely up to what data is supplied.&lt;br /&gt;
== Business Requirement Example ==&lt;br /&gt;
* We need two types of employee permanent and contract.&lt;br /&gt;
* Contract employee's Salary is 80000 and Bonus is 0.&lt;br /&gt;
* Permanent employee's Salary is 50000 and Bonus is 5000.&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
    }&lt;br /&gt;
    class Employees&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 2,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            Employees _contractEmplyee = create(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            Employees _permanentEmplyee = create(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
        }&lt;br /&gt;
        static Employees create(string name,EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            Employees _employee = new Employees();&lt;br /&gt;
            if(employeeType.Id==1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee.Salary = 50000;&lt;br /&gt;
                _employee.Bonus = 5000;&lt;br /&gt;
            }&lt;br /&gt;
            else if(employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee.Salary = 80000;&lt;br /&gt;
                _employee.Bonus = 0;&lt;br /&gt;
            }&lt;br /&gt;
            _employee.EmployeeType = employeeType;&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Problem ==&lt;br /&gt;
The above solves our business requirement but we have some drawbacks..&lt;br /&gt;
* Tightly coupled business logic.&lt;br /&gt;
* Need more development and testing effort when any changes required because we need to update the create() function every-time.&lt;br /&gt;
* Violating [[Single Responsibility Principle]] as '''Main''' function/class is responsible for object creation and payment declaration.&lt;br /&gt;
* Violating [[Open-Closed Principle|Open-Closed-principle]] as we need to change the main function/class every time when we need a new type of employee.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
Let's take a look at the below solution:&lt;br /&gt;
* We have decoupled Employee by using '''IEmployee''' interface. &lt;br /&gt;
* '''EmployeeFactory''' is responsible for object creation. &lt;br /&gt;
* '''Main''' function/class not responsible for object creation, so we don't have to change it when there is an update in salary/bonus or we have a new type of employee. &lt;br /&gt;
=== Code Example ===&lt;br /&gt;
    public interface IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        void setSalary();&lt;br /&gt;
        void setBonus();&lt;br /&gt;
    }&lt;br /&gt;
    class PermanentEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 5000;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 50000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ContractEmployee : IEmployee&lt;br /&gt;
    {&lt;br /&gt;
        public string Name { get; set; }&lt;br /&gt;
        public EmployeeTypes EmployeeType { get; set; }&lt;br /&gt;
        public int Salary { get; set; }&lt;br /&gt;
        public int Bonus { get; set; }&lt;br /&gt;
        public void setBonus()&lt;br /&gt;
        {&lt;br /&gt;
            Bonus = 0;&lt;br /&gt;
        }&lt;br /&gt;
        public void setSalary()&lt;br /&gt;
        {&lt;br /&gt;
            Salary = 80000;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeFactory&lt;br /&gt;
    {&lt;br /&gt;
        public IEmployee GetEmployee(string name, EmployeeTypes employeeType)&lt;br /&gt;
        {&lt;br /&gt;
            IEmployee _employee= null;&lt;br /&gt;
            if (employeeType.Id == 1)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new PermanentEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            else if (employeeType.Id == 2)&lt;br /&gt;
            {&lt;br /&gt;
                _employee = new ContractEmployee()&lt;br /&gt;
                {&lt;br /&gt;
                    Name = name&lt;br /&gt;
                };&lt;br /&gt;
            }&lt;br /&gt;
            return _employee;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class EmployeeTypes&lt;br /&gt;
    {&lt;br /&gt;
        public int Id { get; set; }&lt;br /&gt;
        public string Name { get; set; }&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;
            EmployeeTypes _contractEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Contract Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeTypes _permanentEmplyeeType = new EmployeeTypes&lt;br /&gt;
            {&lt;br /&gt;
                Id = 1,&lt;br /&gt;
                Name = &amp;quot;Permanent Emplyee&amp;quot;&lt;br /&gt;
            };&lt;br /&gt;
            EmployeeFactory employeeFactory = new EmployeeFactory();&lt;br /&gt;
            IEmployee _contractEmplyee = employeeFactory.GetEmployee(&amp;quot;Jhon&amp;quot; , _contractEmplyeeType);&lt;br /&gt;
            _contractEmplyee.setBonus();&lt;br /&gt;
            _contractEmplyee.setSalary();&lt;br /&gt;
            IEmployee _permanentEmplyee = employeeFactory.GetEmployee(&amp;quot;Mario&amp;quot;, _permanentEmplyeeType);&lt;br /&gt;
            _permanentEmplyee.setBonus();&lt;br /&gt;
            _permanentEmplyee.setSalary();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
== Advantage of Simple Factory Pattern ==&lt;br /&gt;
This follows the [[Open-Closed Principle|Open-Closed-principle]]: Our Employee class is closed, as we have a fixed set of Employee, which we hire, but we are open for new Employees.&lt;br /&gt;
&lt;br /&gt;
Further: Each new Employee have their set of functions. The Permanent Employee  doesn't care what/how to do a Contract Employee ([[Single Responsibility Principle]]).&lt;br /&gt;
&lt;br /&gt;
Last but not least, we decoupled different Employee types from the Main function. The main function needs only to know how to handle.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=File:Simple_Factory_Pattern.png&amp;diff=125</id>
		<title>File:Simple Factory Pattern.png</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=File:Simple_Factory_Pattern.png&amp;diff=125"/>
		<updated>2020-02-23T06:31:19Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple Factory Pattern&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Design_Patterns&amp;diff=124</id>
		<title>Design Patterns</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Design_Patterns&amp;diff=124"/>
		<updated>2020-02-21T13:10:29Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Design patterns provide general '''solutions to software design problems''' we find in real-world application development.&lt;br /&gt;
&lt;br /&gt;
Before starting with design patterns let's understand what the meaning of design patterns and why they are useful in software programming/architecture.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Each pattern describes a problem that occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.&amp;quot; - Christopher Alexander, A Pattern Language.&lt;br /&gt;
&lt;br /&gt;
It is important to understand design patterns rather than memorizing their classes, methods and properties. First identify the software design problem then see how to address these problems using design patterns and determine the best suited design problem to solve the problem.&lt;br /&gt;
&lt;br /&gt;
There are 23 design patterns, also known as '''Gang of Four (GoF)''' design patterns. The Gang of Four are the authors of the book, &amp;quot;Design Patterns: Elements of Reusable Object Oriented Software&amp;quot;.&lt;br /&gt;
[[File:Design Patterns.png|none|Design Patterns &amp;amp; Types of Design Patterns]]&lt;br /&gt;
&lt;br /&gt;
== Creational Design Pattern ==&lt;br /&gt;
In software engineering, creational design patterns are design patterns that deal with '''object creation mechanisms''', trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.&lt;br /&gt;
=== Simple Factory ===&lt;br /&gt;
[[Simple Factory Pattern]] returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and common methods, but each may perform a task differently or optimize for different data or behaviors.&lt;br /&gt;
&lt;br /&gt;
=== Factory Method ===&lt;br /&gt;
The [[Factory Method Design Pattern|factory method pattern]] is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory method—either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes—rather than by calling a constructor.&lt;br /&gt;
&lt;br /&gt;
=== Abstract Factory ===&lt;br /&gt;
The [[Abstract Factory Design Pattern|abstract factory pattern]] provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part of the theme. The client doesn't know or care which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
In simple words, It provides an interface for creating families of related or dependent objects without specifying their concrete classes.&lt;br /&gt;
&lt;br /&gt;
=== Builder ===&lt;br /&gt;
The [[Builder Design Pattern|Builder]] is a design pattern designed to provide a flexible solution to various object creation problems in object-oriented programming. The intent of the Builder design pattern is to separate the construction of a complex object from its representation.&lt;br /&gt;
&lt;br /&gt;
In simple words, separating the construction of a complex object from its representation so that the same construction process can create different representations.&lt;br /&gt;
&lt;br /&gt;
=== Prototype ===&lt;br /&gt;
The [[Prototype Design Pattern|prototype pattern]] is a creational design pattern in software development. It is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects.&lt;br /&gt;
&lt;br /&gt;
In simple words, specifying the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.&lt;br /&gt;
&lt;br /&gt;
=== Singleton ===&lt;br /&gt;
The [[Singleton Design Pattern|singleton pattern]] is a software design pattern that restricts the instantiation of a class to one '''single''' instance. This is useful when exactly one object is needed to coordinate actions across the system.&lt;br /&gt;
&lt;br /&gt;
== Structural Design Patterns ==&lt;br /&gt;
=== Adapter ===&lt;br /&gt;
=== Bridge ===&lt;br /&gt;
=== Composite ===&lt;br /&gt;
=== Decorator ===&lt;br /&gt;
=== Façade ===&lt;br /&gt;
=== Flyweight ===&lt;br /&gt;
=== Proxy ===&lt;br /&gt;
== Behavioral Design Patterns ==&lt;br /&gt;
=== Chain of Responsibility ===&lt;br /&gt;
=== Command ===&lt;br /&gt;
=== Interpreter ===&lt;br /&gt;
=== Iterator ===&lt;br /&gt;
=== Mediator ===&lt;br /&gt;
=== Memento ===&lt;br /&gt;
=== Observer ===&lt;br /&gt;
=== State ===&lt;br /&gt;
=== Strategy ===&lt;br /&gt;
=== Visitor ===&lt;br /&gt;
=== Template Method ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Design_Patterns&amp;diff=123</id>
		<title>Design Patterns</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Design_Patterns&amp;diff=123"/>
		<updated>2020-02-18T15:32:59Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Design patterns provide general '''solutions to software design problems''' we find in real-world application development.&lt;br /&gt;
&lt;br /&gt;
Before starting with design patterns let's understand what the meaning of design patterns and why they are useful in software programming/architecture.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Each pattern describes a problem that occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.&amp;quot; - Christopher Alexander, A Pattern Language.&lt;br /&gt;
&lt;br /&gt;
It is important to understand design patterns rather than memorizing their classes, methods and properties. First identify the software design problem then see how to address these problems using design patterns and determine the best suited design problem to solve the problem.&lt;br /&gt;
&lt;br /&gt;
There are 23 design patterns, also known as '''Gang of Four (GoF)''' design patterns. The Gang of Four are the authors of the book, &amp;quot;Design Patterns: Elements of Reusable Object Oriented Software&amp;quot;.&lt;br /&gt;
[[File:Design Patterns.png|none|Design Patterns &amp;amp; Types of Design Patterns]]&lt;br /&gt;
&lt;br /&gt;
== Creational Design Pattern ==&lt;br /&gt;
In software engineering, creational design patterns are design patterns that deal with '''object creation mechanisms''', trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.&lt;br /&gt;
== Simple Factory ==&lt;br /&gt;
[[Simple Factory Pattern]] returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and common methods, but each may perform a task differently or optimize for different data or behaviors.&lt;br /&gt;
&lt;br /&gt;
=== Factory Method ===&lt;br /&gt;
The [[Factory Method Design Pattern|factory method pattern]] is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory method—either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes—rather than by calling a constructor.&lt;br /&gt;
&lt;br /&gt;
=== Abstract Factory ===&lt;br /&gt;
The [[Abstract Factory Design Pattern|abstract factory pattern]] provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part of the theme. The client doesn't know or care which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
In simple words, It provides an interface for creating families of related or dependent objects without specifying their concrete classes.&lt;br /&gt;
&lt;br /&gt;
=== Builder ===&lt;br /&gt;
The [[Builder Design Pattern|Builder]] is a design pattern designed to provide a flexible solution to various object creation problems in object-oriented programming. The intent of the Builder design pattern is to separate the construction of a complex object from its representation.&lt;br /&gt;
&lt;br /&gt;
In simple words, separating the construction of a complex object from its representation so that the same construction process can create different representations.&lt;br /&gt;
&lt;br /&gt;
=== Prototype ===&lt;br /&gt;
The [[Prototype Design Pattern|prototype pattern]] is a creational design pattern in software development. It is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects.&lt;br /&gt;
&lt;br /&gt;
In simple words, specifying the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.&lt;br /&gt;
&lt;br /&gt;
=== Singleton ===&lt;br /&gt;
The [[Singleton Design Pattern|singleton pattern]] is a software design pattern that restricts the instantiation of a class to one '''single''' instance. This is useful when exactly one object is needed to coordinate actions across the system.&lt;br /&gt;
&lt;br /&gt;
== Structural Design Patterns ==&lt;br /&gt;
=== Adapter ===&lt;br /&gt;
=== Bridge ===&lt;br /&gt;
=== Composite ===&lt;br /&gt;
=== Decorator ===&lt;br /&gt;
=== Façade ===&lt;br /&gt;
=== Flyweight ===&lt;br /&gt;
=== Proxy ===&lt;br /&gt;
== Behavioral Design Patterns ==&lt;br /&gt;
=== Chain of Responsibility ===&lt;br /&gt;
=== Command ===&lt;br /&gt;
=== Interpreter ===&lt;br /&gt;
=== Iterator ===&lt;br /&gt;
=== Mediator ===&lt;br /&gt;
=== Memento ===&lt;br /&gt;
=== Observer ===&lt;br /&gt;
=== State ===&lt;br /&gt;
=== Strategy ===&lt;br /&gt;
=== Visitor ===&lt;br /&gt;
=== Template Method ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=122</id>
		<title>Simple Factory Pattern</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Simple_Factory_Pattern&amp;diff=122"/>
		<updated>2020-02-18T15:32:31Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;Simple Factory Pattern returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and co...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple Factory Pattern returns an instance of one of several possible classes depending on the type of data provided. It is quite common to return a common parent class and common methods, but each may perform a task differently or optimize for different data or behaviors.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Abstraction&amp;diff=121</id>
		<title>Abstraction</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Abstraction&amp;diff=121"/>
		<updated>2020-02-11T03:28:36Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Abstraction''' is the process representing essential features without including background details, to reduce the complexity for the users. Abstraction can be achieved with either abstract classes or interfaces.&lt;br /&gt;
== Abstract class &amp;amp; Abstract method ==&lt;br /&gt;
'''Abstract''' keyword is used with classes and methods:&lt;br /&gt;
&lt;br /&gt;
* '''Abstract class''' is a restricted class that cannot be used to create objects. To access it, it must be inherited from another class.&lt;br /&gt;
* '''Abstract method''' can only be used in an abstract class, and it does not have a body. The body is provided by the derived class.&lt;br /&gt;
&lt;br /&gt;
    abstract class Software&lt;br /&gt;
    {&lt;br /&gt;
        // Abstract method (does not have a body)&lt;br /&gt;
        public abstract void addIcon();&lt;br /&gt;
        // Regular method&lt;br /&gt;
        public void defaltPath()&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;c:&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    // Derived class (inherit from Software)&lt;br /&gt;
    class WinZip : Software&lt;br /&gt;
    {&lt;br /&gt;
        public override void addIcon()&lt;br /&gt;
        {&lt;br /&gt;
            // The body of addIcon() is provided here&lt;br /&gt;
            Console.WriteLine(&amp;quot;Desktop&amp;quot;);&lt;br /&gt;
        }&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;
            WinZip myWinZip = new WinZip(); // Create a WinZip object&lt;br /&gt;
            myWinZip.defaltPath();  // Call the abstract method&lt;br /&gt;
            myWinZip.addIcon();  // Call the regular method&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Interface ==&lt;br /&gt;
An interface is a completely &amp;quot;abstract class&amp;quot;, which can only contain abstract methods and properties (with empty bodies). Interface is another way to achieve abstraction in C#.&lt;br /&gt;
&lt;br /&gt;
    interface Software&lt;br /&gt;
    {&lt;br /&gt;
        // Abstract method (does not have a body)&lt;br /&gt;
        void addIcon();&lt;br /&gt;
        // Abstract method (does not have a body)&lt;br /&gt;
        void defaltPath();&lt;br /&gt;
    }&lt;br /&gt;
    // Derived class (inherit from Software)&lt;br /&gt;
    class WinZip : Software&lt;br /&gt;
    {&lt;br /&gt;
        public void addIcon()&lt;br /&gt;
        {&lt;br /&gt;
            // The body of addIcon() is provided here&lt;br /&gt;
            Console.WriteLine(&amp;quot;Desktop&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        public void defaltPath()&lt;br /&gt;
        {&lt;br /&gt;
            // The body of defaltPath() is provided here&lt;br /&gt;
            Console.WriteLine(&amp;quot;c:&amp;quot;);&lt;br /&gt;
        }&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;
            WinZip myWinZip = new WinZip(); // Create a WinZip object&lt;br /&gt;
            myWinZip.defaltPath();  // Call the regular method&lt;br /&gt;
            myWinZip.addIcon();  // Call the regular method&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Garbage_Collection&amp;diff=120</id>
		<title>Garbage Collection</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Garbage_Collection&amp;diff=120"/>
		<updated>2020-02-08T16:25:47Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The garbage collector (GC) serves as an automatic memory manager in the common language runtime (CLR). When a class object is created at runtime, certain memory space is allocated to it in the heap memory. However, after all the actions related to the object are completed in the program, the memory space allocated to it is a waste as it cannot be used. In this case, garbage collection is very useful as it automatically releases the memory space after it is no longer required.&lt;br /&gt;
&lt;br /&gt;
== Advantages of Garbage Collection ==&lt;br /&gt;
* You don’t need to free memory manually while developing your application.&lt;br /&gt;
* It also allocates objects on the managed heap efficiently.&lt;br /&gt;
* When objects are no longer used then it will reclaim those objects by clearing their memory, and keeps the memory available for future allocations.&lt;br /&gt;
* Managed objects automatically get clean content to start with, so their constructors do not have to initialize every data field.&lt;br /&gt;
&lt;br /&gt;
== When Garbage Collection Works ==&lt;br /&gt;
Garbage Collection occurs if at least one of multiple conditions is satisfied. These conditions are given as follows:&lt;br /&gt;
&lt;br /&gt;
* When virtual memory is running out of space.&lt;br /&gt;
* When allocated memory is suppressed acceptable threshold (when GC found if the survival rate (living objects) is high, then it increases the threshold allocation).&lt;br /&gt;
* When we call '''GC.Collect()''' method explicitly, as GC runs continuously, we actually do not need to call this method.&lt;br /&gt;
&lt;br /&gt;
== Generations ==&lt;br /&gt;
Memory is divided into spaces called '''generations''' so it can handle long-lived and short-lived objects. Garbage collection primarily occurs with the reclamation of short-lived objects that typically occupy only a small part of the heap. There are three generations of objects on the heap:&lt;br /&gt;
=== Generation 0 ===&lt;br /&gt;
This is the youngest generation and contains short-lived objects. An example of a short-lived object is a temporary variable. Garbage collection occurs most frequently in this generation.&lt;br /&gt;
&lt;br /&gt;
Newly allocated objects form a new generation of objects and are implicitly generation 0 collections. However, if they are large objects, they go on the large object heap in a generation 2 collection.&lt;br /&gt;
&lt;br /&gt;
Most objects are reclaimed for garbage collection in generation 0 and do not survive to the next generation. &lt;br /&gt;
=== Generation 1 === &lt;br /&gt;
This generation contains short-lived objects and serves as a buffer between short-lived objects and long-lived objects.&lt;br /&gt;
=== Generation 2 ===&lt;br /&gt;
This generation contains long-lived objects. An example of a long-lived object is an object in a server application that contains static data that's live for the duration of the process.&lt;br /&gt;
&lt;br /&gt;
Generation 2 garbage collection is also known as a full garbage collection, because it reclaims all objects in all generations (that is, all objects in the managed heap).&lt;br /&gt;
&lt;br /&gt;
== Phases ==&lt;br /&gt;
A garbage collection has the following 3 phases:&lt;br /&gt;
# '''Marking Phase''': A list of all the live objects is created during the marking phase. This is done by following the references from all the root objects. All of the objects that are not on the list of live objects are potentially deleted from the heap memory. &lt;br /&gt;
# '''Relocating Phase''': The references of all the objects that were on the list of all the live objects are updated in the relocating phase so that they point to the new location where the objects will be relocated to in the compacting phase. &lt;br /&gt;
# '''Compacting Phase''': The heap gets compacted in the compacting phase as the space occupied by the dead objects is released and the live objects remaining are moved. All the live objects that remain after the garbage collection are moved towards the older end of the &lt;br /&gt;
heap memory in their original order.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Garbage_Collection&amp;diff=119</id>
		<title>Garbage Collection</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Garbage_Collection&amp;diff=119"/>
		<updated>2020-02-08T15:33:43Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;The garbage collector (GC) serves as an automatic memory manager in the common language runtime (CLR). When a class object is created at runtime, certain memory space is alloc...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The garbage collector (GC) serves as an automatic memory manager in the common language runtime (CLR). When a class object is created at runtime, certain memory space is allocated to it in the heap memory. However, after all the actions related to the object are completed in the program, the memory space allocated to it is a waste as it cannot be used. In this case, garbage collection is very useful as it automatically releases the memory space after it is no longer required.&lt;br /&gt;
&lt;br /&gt;
== Advantages of Garbage Collection ==&lt;br /&gt;
* You don’t need to free memory manually while developing your application.&lt;br /&gt;
* It also allocates objects on the managed heap efficiently.&lt;br /&gt;
* When objects are no longer used then it will reclaim those objects by clearing their memory, and keeps the memory available for future allocations.&lt;br /&gt;
* Managed objects automatically get clean content to start with, so their constructors do not have to initialize every data field.&lt;br /&gt;
&lt;br /&gt;
== When Garbage Collection Works ==&lt;br /&gt;
Garbage Collection occurs if at least one of multiple conditions is satisfied. These conditions are given as follows:&lt;br /&gt;
&lt;br /&gt;
* When virtual memory is running out of space.&lt;br /&gt;
* When allocated memory is suppressed acceptable threshold (when GC found if the survival rate (living objects) is high, then it increases the threshold allocation).&lt;br /&gt;
* When we call GC.Collect() method explicitly, as GC runs continuously, we actually do not need to call this method.&lt;br /&gt;
&lt;br /&gt;
== Generations ==&lt;br /&gt;
Memory is divided into spaces called '''generations''' so it can handle long-lived and short-lived objects. Garbage collection primarily occurs with the reclamation of short-lived objects that typically occupy only a small part of the heap. There are three generations of objects on the heap:&lt;br /&gt;
=== Generation 0 ===&lt;br /&gt;
This is the youngest generation and contains short-lived objects. An example of a short-lived object is a temporary variable. Garbage collection occurs most frequently in this generation.&lt;br /&gt;
&lt;br /&gt;
Newly allocated objects form a new generation of objects and are implicitly generation 0 collections. However, if they are large objects, they go on the large object heap in a generation 2 collection.&lt;br /&gt;
&lt;br /&gt;
Most objects are reclaimed for garbage collection in generation 0 and do not survive to the next generation. &lt;br /&gt;
=== Generation 1 === &lt;br /&gt;
This generation contains short-lived objects and serves as a buffer between short-lived objects and long-lived objects.&lt;br /&gt;
=== Generation 2 ===&lt;br /&gt;
This generation contains long-lived objects. An example of a long-lived object is an object in a server application that contains static data that's live for the duration of the process.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=118</id>
		<title>State Management in ASP.NET</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=118"/>
		<updated>2020-02-04T17:52:56Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Query Strings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in the past.&lt;br /&gt;
&lt;br /&gt;
Stateless means, whenever we visit a website, our browser communicates with the respective server depending on our requested functionality or the request. In this case HTTP/HTTPs doesn't remember what website or URL we visited, or in other words we can say it doesn't hold the state of a previous website that we visited before closing our browser, that is called stateless.&lt;br /&gt;
&lt;br /&gt;
So our browsers are stateless.&lt;br /&gt;
&lt;br /&gt;
== State Management Types ==&lt;br /&gt;
[[File:State Management Techniques.png|none|State Management Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Client-side | Techniques ==&lt;br /&gt;
=== View State ===&lt;br /&gt;
[[ASP.NET View State|View State]] is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.Please keep in mind though, that while cookies and sessions can be accessed from all your pages on your website, ViewState values are not carried between pages.&lt;br /&gt;
 &lt;br /&gt;
=== Hidden field ===&lt;br /&gt;
[[ASP.NET Hidden Field|Hidden Field]] is non visual control in ASP.NET where we can save the value. This is one of the types of client-side state management tools. It stores the value between the roundtrip. Anyone can see Hidden Field details by simply viewing the source of document.&lt;br /&gt;
=== Cookies ===&lt;br /&gt;
[[ASP.NET Cookies|Cookies]] is a small piece of information stored on the client machine. Its is used to store user preference information like Password, City, SessionId etc on client machines. We need to import namespace called Systen.Web before we use cookie(HttpCookie).&lt;br /&gt;
=== Control State ===&lt;br /&gt;
The '''control state''' is a way to save a control’s state information when the EnableViewState property is turned off. Unlike ViewState a developer can’t turn off control state. The control state can be implemented only in controls that you implement. ControlState is used to store small amounts of critical information. Heavy usage of ControlState can impact the performance of application because it involves '''serialization''' and '''deserialization''' for its functioning.&lt;br /&gt;
&lt;br /&gt;
There are two methods('''SaveControlState''' and '''LoadControlState''') which we have to implement in your custom control and on '''OnInit''' method of the control we need to add the call for the '''Page.RegisterRequiresControlState()''' method with the instance of the control to register.&lt;br /&gt;
&lt;br /&gt;
    public class ControlWebControl : Control&lt;br /&gt;
    {&lt;br /&gt;
        private string _strStateToSave;&lt;br /&gt;
        protected override void OnInit(EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
            Page.RegisterRequiresControlState(this);&lt;br /&gt;
            base.OnInit(e);&lt;br /&gt;
        }&lt;br /&gt;
        protected override object SaveControlState()&lt;br /&gt;
        {&lt;br /&gt;
            return _strStateToSave;&lt;br /&gt;
        }&lt;br /&gt;
        protected override void LoadControlState(object state)&lt;br /&gt;
        {&lt;br /&gt;
            if (state != null)&lt;br /&gt;
            {&lt;br /&gt;
                _strStateToSave = state.ToString();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== Query Strings ===&lt;br /&gt;
[[ASP.NET Query Strings|Query string]] is one of the techniques in Web applications to send data from one page to another. A query string consists of two parts, field and value, and each of pair separated by ampersand (&amp;amp;). The ?(question mark in a query string indicates the beginning of a query string and it's value.&lt;br /&gt;
&lt;br /&gt;
== Server-side | Technique ==&lt;br /&gt;
=== Session State ===&lt;br /&gt;
==== InProc ====&lt;br /&gt;
==== OutProc ====&lt;br /&gt;
=== Application State ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=ASP.NET_Query_Strings&amp;diff=117</id>
		<title>ASP.NET Query Strings</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=ASP.NET_Query_Strings&amp;diff=117"/>
		<updated>2020-02-04T17:51:46Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Query string''' is one of the techniques in Web applications to send data from one page to another. A query string consists of two parts, field and value, and each of pair separated by ampersand ('''&amp;amp;''').&lt;br /&gt;
 &lt;br /&gt;
The '''?'''(question mark in a query string indicates the beginning of a query string and it's value.&lt;br /&gt;
 &lt;br /&gt;
Query strings cannot be used to send very long data as there is a limit on the Query string length.&lt;br /&gt;
&lt;br /&gt;
Query strings are visible to the user, hence should not be used to send sensitive information suck as a username and password, unless encrypted.&lt;br /&gt;
 &lt;br /&gt;
To retrieve the query string value, use Request object's Query String property.&lt;br /&gt;
&lt;br /&gt;
    Request.QueryString(variable)[(index) |.Count]&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter !! Description&lt;br /&gt;
|-&lt;br /&gt;
| variable || Required. The name of the variable in the HTTP query string to retrieve&lt;br /&gt;
|-&lt;br /&gt;
| index || Optional. Specifies one of multiple values for a variable. From 1 to Request.QueryString(variable).Count&lt;br /&gt;
|}&lt;br /&gt;
URL in browser:&lt;br /&gt;
    https://jholjhapata.com/wiki/ASP.NET_Query_Strings?firstname=Soumya&amp;amp;lastname=Das&lt;br /&gt;
'''Query string is''': firstname=Soumya and lastname=Das&lt;br /&gt;
&lt;br /&gt;
C# code to get Query string values on page:&lt;br /&gt;
    string firstname = Request.QueryString[&amp;quot;firstname&amp;quot;];&lt;br /&gt;
    string lastname = Request.QueryString[&amp;quot;lastname&amp;quot;];&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=ASP.NET_Query_Strings&amp;diff=116</id>
		<title>ASP.NET Query Strings</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=ASP.NET_Query_Strings&amp;diff=116"/>
		<updated>2020-02-02T17:32:15Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;'''Query string''' is one of the techniques in Web applications to send data from one page to another. A query string consists of two parts, field and value, and each of pair...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Query string''' is one of the techniques in Web applications to send data from one page to another. A query string consists of two parts, field and value, and each of pair separated by ampersand ('''&amp;amp;''').&lt;br /&gt;
 &lt;br /&gt;
The '''?'''(question mark in a query string indicates the beginning of a query string and it's value.&lt;br /&gt;
 &lt;br /&gt;
Query strings cannot be used to send very long data as there is a limit on the Query string length.&lt;br /&gt;
&lt;br /&gt;
Query strings are visible to the user, hence should not be used to send sensitive information suck as a username and password, unless encrypted.&lt;br /&gt;
 &lt;br /&gt;
To retrieve the query string value, use Request object's Query String property.&lt;br /&gt;
&lt;br /&gt;
    Request.QueryString(variable)[(index) |.Count]&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter !! Description&lt;br /&gt;
|-&lt;br /&gt;
| variable || Required. The name of the variable in the HTTP query string to retrieve&lt;br /&gt;
|-&lt;br /&gt;
| index || Optional. Specifies one of multiple values for a variable. From 1 to Request.QueryString(variable).Count&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=115</id>
		<title>State Management in ASP.NET</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=115"/>
		<updated>2020-02-02T15:02:40Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Control State */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in the past.&lt;br /&gt;
&lt;br /&gt;
Stateless means, whenever we visit a website, our browser communicates with the respective server depending on our requested functionality or the request. In this case HTTP/HTTPs doesn't remember what website or URL we visited, or in other words we can say it doesn't hold the state of a previous website that we visited before closing our browser, that is called stateless.&lt;br /&gt;
&lt;br /&gt;
So our browsers are stateless.&lt;br /&gt;
&lt;br /&gt;
== State Management Types ==&lt;br /&gt;
[[File:State Management Techniques.png|none|State Management Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Client-side | Techniques ==&lt;br /&gt;
=== View State ===&lt;br /&gt;
[[ASP.NET View State|View State]] is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.Please keep in mind though, that while cookies and sessions can be accessed from all your pages on your website, ViewState values are not carried between pages.&lt;br /&gt;
 &lt;br /&gt;
=== Hidden field ===&lt;br /&gt;
[[ASP.NET Hidden Field|Hidden Field]] is non visual control in ASP.NET where we can save the value. This is one of the types of client-side state management tools. It stores the value between the roundtrip. Anyone can see Hidden Field details by simply viewing the source of document.&lt;br /&gt;
=== Cookies ===&lt;br /&gt;
[[ASP.NET Cookies|Cookies]] is a small piece of information stored on the client machine. Its is used to store user preference information like Password, City, SessionId etc on client machines. We need to import namespace called Systen.Web before we use cookie(HttpCookie).&lt;br /&gt;
=== Control State ===&lt;br /&gt;
The '''control state''' is a way to save a control’s state information when the EnableViewState property is turned off. Unlike ViewState a developer can’t turn off control state. The control state can be implemented only in controls that you implement. ControlState is used to store small amounts of critical information. Heavy usage of ControlState can impact the performance of application because it involves '''serialization''' and '''deserialization''' for its functioning.&lt;br /&gt;
&lt;br /&gt;
There are two methods('''SaveControlState''' and '''LoadControlState''') which we have to implement in your custom control and on '''OnInit''' method of the control we need to add the call for the '''Page.RegisterRequiresControlState()''' method with the instance of the control to register.&lt;br /&gt;
&lt;br /&gt;
    public class ControlWebControl : Control&lt;br /&gt;
    {&lt;br /&gt;
        private string _strStateToSave;&lt;br /&gt;
        protected override void OnInit(EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
            Page.RegisterRequiresControlState(this);&lt;br /&gt;
            base.OnInit(e);&lt;br /&gt;
        }&lt;br /&gt;
        protected override object SaveControlState()&lt;br /&gt;
        {&lt;br /&gt;
            return _strStateToSave;&lt;br /&gt;
        }&lt;br /&gt;
        protected override void LoadControlState(object state)&lt;br /&gt;
        {&lt;br /&gt;
            if (state != null)&lt;br /&gt;
            {&lt;br /&gt;
                _strStateToSave = state.ToString();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== Query Strings ===&lt;br /&gt;
== Server-side | Technique ==&lt;br /&gt;
=== Session State ===&lt;br /&gt;
==== InProc ====&lt;br /&gt;
==== OutProc ====&lt;br /&gt;
=== Application State ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=114</id>
		<title>State Management in ASP.NET</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=114"/>
		<updated>2020-01-23T16:12:16Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in the past.&lt;br /&gt;
&lt;br /&gt;
Stateless means, whenever we visit a website, our browser communicates with the respective server depending on our requested functionality or the request. In this case HTTP/HTTPs doesn't remember what website or URL we visited, or in other words we can say it doesn't hold the state of a previous website that we visited before closing our browser, that is called stateless.&lt;br /&gt;
&lt;br /&gt;
So our browsers are stateless.&lt;br /&gt;
&lt;br /&gt;
== State Management Types ==&lt;br /&gt;
[[File:State Management Techniques.png|none|State Management Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Client-side | Techniques ==&lt;br /&gt;
=== View State ===&lt;br /&gt;
[[ASP.NET View State|View State]] is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.Please keep in mind though, that while cookies and sessions can be accessed from all your pages on your website, ViewState values are not carried between pages.&lt;br /&gt;
 &lt;br /&gt;
=== Hidden field ===&lt;br /&gt;
[[ASP.NET Hidden Field|Hidden Field]] is non visual control in ASP.NET where we can save the value. This is one of the types of client-side state management tools. It stores the value between the roundtrip. Anyone can see Hidden Field details by simply viewing the source of document.&lt;br /&gt;
=== Cookies ===&lt;br /&gt;
[[ASP.NET Cookies|Cookies]] is a small piece of information stored on the client machine. Its is used to store user preference information like Password, City, SessionId etc on client machines. We need to import namespace called Systen.Web before we use cookie(HttpCookie).&lt;br /&gt;
=== Control State ===&lt;br /&gt;
=== Query Strings ===&lt;br /&gt;
== Server-side | Technique ==&lt;br /&gt;
=== Session State ===&lt;br /&gt;
==== InProc ====&lt;br /&gt;
==== OutProc ====&lt;br /&gt;
=== Application State ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=ASP.NET_Cookies&amp;diff=113</id>
		<title>ASP.NET Cookies</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=ASP.NET_Cookies&amp;diff=113"/>
		<updated>2020-01-23T16:11:24Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;Cookies is a small piece of information stored on the client machine. Its is used to store user preference information like Password, City, SessionId etc on client machines. W...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cookies is a small piece of information stored on the client machine. Its is used to store user preference information like Password, City, SessionId etc on client machines. We need to import namespace called  Systen.Web before we use cookie(HttpCookie).&lt;br /&gt;
== Type of Cookies ==&lt;br /&gt;
* '''Persistent Cookie''' - Persistent cookies are permanent cookies.They are stored as a text file in the hard disk of the computer.&lt;br /&gt;
* '''Non-Persistent Cookie''' - These cookies are also known as temporary cookies or session based cookies.They are active as long as the browser remains active. Once the browser is closed the cookies vanishes automatically. &lt;br /&gt;
== Create a cookie ==&lt;br /&gt;
In the Asp.Net with help of Response object or HttpCookie we can create a cookie.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
    HttpCookie info = new HttpCookie(&amp;quot;info&amp;quot;);&lt;br /&gt;
    info[&amp;quot;UserFirstName&amp;quot;] = &amp;quot;Soumya&amp;quot;;&lt;br /&gt;
    info[&amp;quot;UserLastName&amp;quot;] = &amp;quot;Das&amp;quot;;&lt;br /&gt;
    info.Expires.Add(new TimeSpan(0, 1, 0));&lt;br /&gt;
    Response.Cookies.Add(info);&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
    Response.Cookies[&amp;quot;UserFirstName&amp;quot;].Value = &amp;quot;Annathurai&amp;quot;;&lt;br /&gt;
    Response.Cookies[&amp;quot;UserLastName&amp;quot;].Value = &amp;quot;Black&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
== Retrieve value from cookie ==&lt;br /&gt;
In the Asp.Net with help of Response object or HttpCookie we can retrieve cookies.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
    string UserFirstName = Request.Cookies[&amp;quot;UserFirstName&amp;quot;].Value;&lt;br /&gt;
    string UserLastName =  Request.Cookies[&amp;quot;UserLastName&amp;quot;].Value;&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
    HttpCookie reqCookies = Request.Cookies[&amp;quot;userInfo&amp;quot;];&lt;br /&gt;
    if (reqCookies != null)&lt;br /&gt;
    {&lt;br /&gt;
        string UserFirstName = reqCookies[&amp;quot;UserFirstName&amp;quot;].ToString();&lt;br /&gt;
        string UserLastName = reqCookies[&amp;quot;UserLastName&amp;quot;].ToString();&lt;br /&gt;
    }&lt;br /&gt;
== Cookie's property ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Property !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Domain || Which is used to associate cookies to domain.&lt;br /&gt;
|-&lt;br /&gt;
| Secure || We can enable secure cookie to set true(HTTPs).&lt;br /&gt;
|-&lt;br /&gt;
| Value || We can manipulate individual cookie.&lt;br /&gt;
|-&lt;br /&gt;
| Values || We can manipulate cookies with key/value pair.&lt;br /&gt;
|-&lt;br /&gt;
| Expires || Which is used to set expire date for the cookies.&lt;br /&gt;
|}&lt;br /&gt;
== Advantages of Cookie ==&lt;br /&gt;
* Its clear text so user can able to read it.&lt;br /&gt;
* We can store user preference information on the client machine.&lt;br /&gt;
* Its easy way to maintain.&lt;br /&gt;
* Fast accessing.&lt;br /&gt;
== Disadvantages of Cookie ==&lt;br /&gt;
* If user clear cookie information we can't get it back.&lt;br /&gt;
* No security.&lt;br /&gt;
* Each request will have cookie information with page.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=112</id>
		<title>State Management in ASP.NET</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=112"/>
		<updated>2020-01-23T15:13:53Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in the past.&lt;br /&gt;
&lt;br /&gt;
Stateless means, whenever we visit a website, our browser communicates with the respective server depending on our requested functionality or the request. In this case HTTP/HTTPs doesn't remember what website or URL we visited, or in other words we can say it doesn't hold the state of a previous website that we visited before closing our browser, that is called stateless.&lt;br /&gt;
&lt;br /&gt;
So our browsers are stateless.&lt;br /&gt;
&lt;br /&gt;
== State Management Types ==&lt;br /&gt;
[[File:State Management Techniques.png|none|State Management Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Client-side | Techniques ==&lt;br /&gt;
=== View State ===&lt;br /&gt;
[[ASP.NET View State|View State]] is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.Please keep in mind though, that while cookies and sessions can be accessed from all your pages on your website, ViewState values are not carried between pages.&lt;br /&gt;
 &lt;br /&gt;
=== Hidden field ===&lt;br /&gt;
[[ASP.NET Hidden Field|Hidden Field]] is non visual control in ASP.NET where we can save the value. This is one of the types of client-side state management tools. It stores the value between the roundtrip. Anyone can see Hidden Field details by simply viewing the source of document.&lt;br /&gt;
=== Cookies ===&lt;br /&gt;
=== Control State ===&lt;br /&gt;
=== Query Strings ===&lt;br /&gt;
== Server-side | Technique ==&lt;br /&gt;
=== Session State ===&lt;br /&gt;
==== InProc ====&lt;br /&gt;
==== OutProc ====&lt;br /&gt;
=== Application State ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=ASP.NET_Hidden_Field&amp;diff=111</id>
		<title>ASP.NET Hidden Field</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=ASP.NET_Hidden_Field&amp;diff=111"/>
		<updated>2020-01-23T15:13:06Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;Hidden Field is non visual control in ASP.NET where we can save the value. This is one of the types of client-side state management tools. It s...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hidden Field is non visual control in ASP.NET where we can save the value. This is one of the types of client-side [[State Management in ASP.NET|state management tools]]. It stores the value between the roundtrip. Anyone can see Hidden Field details by simply viewing the source of document.&lt;br /&gt;
 &lt;br /&gt;
Hidden Fields are not encrypted or protected and can be changed by anyone. However, from a security point of view, this is not suggested. ASP.NET uses HiddenField control for managing the [[ASP.NET View State|ViewState]]. So, don’t store any important or confidential data like password, etc. with this control.&lt;br /&gt;
== Using Hidden Field ==&lt;br /&gt;
We developers mostly do not show an ID value of table like UserID, ItemID, etc. because users are not concerned with this kind of data. We store that information in HiddenFields to complete our process easily.&lt;br /&gt;
== Events of Hidden Field ==&lt;br /&gt;
As a control, it has events, which are as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! EVENT TYPE !! DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
| DataBinding || Occurs when Server Control binds to a data source.&lt;br /&gt;
|-&lt;br /&gt;
| Disposed|| Occurs when Server Control is released from the memory.&lt;br /&gt;
|-&lt;br /&gt;
| Init || Occurs when Server Control is initialized.&lt;br /&gt;
|-&lt;br /&gt;
| Load || Occurs when server control get loaded on the page.&lt;br /&gt;
|-&lt;br /&gt;
| PreRender || Occurs before Rendering the page.&lt;br /&gt;
|-&lt;br /&gt;
| UnLoad || Occurs when Server Control is unloaded from memory.&lt;br /&gt;
|-&lt;br /&gt;
| ValueChanged || Occurs when the value gets changed between the round-trip (postback).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
ValueChanged event is server-side control. This event gets executed when the value of HiddenField gets changed between postback to the Server.&lt;br /&gt;
 &lt;br /&gt;
Now people avoid to use server side ValueChanged Event as all these things are possible through JavaScript or jQuery easily.&lt;br /&gt;
== Store the value in Hidden Field ==&lt;br /&gt;
    &amp;lt;asp:HiddenFieldID=&amp;quot;hdnfldCurrentDateTime&amp;quot; runat=&amp;quot;server&amp;quot; /&amp;gt;&lt;br /&gt;
== Retrieve the value from Hidden Field ==&lt;br /&gt;
    protectedvoid Page_Load(object sender, EventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
        hdnfldCurrentDateTime.Value = DateTime.Now.ToString();&lt;br /&gt;
    }&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=110</id>
		<title>State Management in ASP.NET</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=110"/>
		<updated>2020-01-23T14:48:30Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in the past.&lt;br /&gt;
&lt;br /&gt;
Stateless means, whenever we visit a website, our browser communicates with the respective server depending on our requested functionality or the request. In this case HTTP/HTTPs doesn't remember what website or URL we visited, or in other words we can say it doesn't hold the state of a previous website that we visited before closing our browser, that is called stateless.&lt;br /&gt;
&lt;br /&gt;
So our browsers are stateless.&lt;br /&gt;
&lt;br /&gt;
== State Management Types ==&lt;br /&gt;
[[File:State Management Techniques.png|none|State Management Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Client-side | Techniques ==&lt;br /&gt;
=== View State ===&lt;br /&gt;
[[ASP.NET View State|View State]] is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.Please keep in mind though, that while cookies and sessions can be accessed from all your pages on your website, ViewState values are not carried between pages.&lt;br /&gt;
 &lt;br /&gt;
=== Hidden field ===&lt;br /&gt;
=== Cookies ===&lt;br /&gt;
=== Control State ===&lt;br /&gt;
=== Query Strings ===&lt;br /&gt;
== Server-side | Technique ==&lt;br /&gt;
=== Session State ===&lt;br /&gt;
==== InProc ====&lt;br /&gt;
==== OutProc ====&lt;br /&gt;
=== Application State ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=ASP.NET_View_State&amp;diff=109</id>
		<title>ASP.NET View State</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=ASP.NET_View_State&amp;diff=109"/>
		<updated>2020-01-23T14:48:04Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.Please keep in mind though, that while cookies and sessions can be accessed from all your pages on your website, ViewState values are not carried between pages.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Points of ViewState ==&lt;br /&gt;
* ViewState does not hold the controls, rather it holds the values of the form controls and their corresponding ID's that would otherwise be lost due to a post back because they do not post with the form.  &lt;br /&gt;
* ViewState is not used to hold session data or to transmit data between pages.&lt;br /&gt;
* ViewState does not recreate the dynamically created controls of a page.&lt;br /&gt;
* It does not restore the values to the controls after a post back operation.&lt;br /&gt;
* ViewState for a control is disabled, still the value would be retained after a post back of the page occurs, for input controls like TextBox or DropDownList.&lt;br /&gt;
  &lt;br /&gt;
So, ViewState represents the state of a page when it was last processed on the web server.  It holds the values of a control that has been dynamically changed.&lt;br /&gt;
&lt;br /&gt;
== How does ViewState work? ==&lt;br /&gt;
&lt;br /&gt;
When the page is first created all controls are serialized to the ViewState, which is rendered as a hidden form field named __ViewState.  This hidden field corresponds to the server side object known as the ViewState.  ViewState for a page is stored as key-value pairs using the System.Web.UI.StateBag object.  When a post back occurs, the page de-serializes the ViewState and recreates all controls.  The ViewState for the controls in a page is stored as base 64 encoded strings in name - value pairs.  When a page is reloaded two methods pertaining to ViewState are called, namely the LoadViewState method and SaveViewState method.  The following is the content of the __ViewState hidden field as generated for a page in my system.&lt;br /&gt;
&lt;br /&gt;
[[File:ViewState.png|ViewState]]&lt;br /&gt;
&lt;br /&gt;
== ViewState can be enabled and disabled in any of the following ways ==&lt;br /&gt;
=== Control Level ===&lt;br /&gt;
To disable ViewState for a single control on a page, we need to set the EnableViewState property of the control to false:&lt;br /&gt;
    &amp;lt;asp:DropDownList ID=&amp;quot;DropDownList1&amp;quot; runat=&amp;quot;server&amp;quot; EnableViewState=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/asp:DropDownList&amp;gt;&lt;br /&gt;
=== Page Level ===&lt;br /&gt;
To disable ViewState for a single page, set the EnableViewState attribute in the @ Page directive to false:&lt;br /&gt;
    &amp;lt;%@ Page Title=&amp;quot;Home Page&amp;quot; Language=&amp;quot;C#&amp;quot;  EnableViewState=&amp;quot;false&amp;quot;  %&amp;gt;&lt;br /&gt;
We can also disable it by adding code in '''Class file''' of the page.&lt;br /&gt;
    private void Page_Init(object sender, System.EventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
        this.EnableViewState = false;&lt;br /&gt;
    }&lt;br /&gt;
=== Application Level ===&lt;br /&gt;
To disable ViewState for a specific application, use the following element in the Web.config file.&lt;br /&gt;
  &amp;lt;configuration&amp;gt;&lt;br /&gt;
    &amp;lt;system.web&amp;gt;&lt;br /&gt;
      &amp;lt;pages enableViewState=&amp;quot;false&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/system.web&amp;gt;&lt;br /&gt;
  &amp;lt;/configuration&amp;gt;&lt;br /&gt;
If you decide later that you need the ViewState for a specific page then you can turn it back on for just that page using a &amp;lt;location&amp;gt; element.&lt;br /&gt;
  &amp;lt;configuration&amp;gt;&lt;br /&gt;
    &amp;lt;system.web&amp;gt;&lt;br /&gt;
      &amp;lt;pages enableViewState=&amp;quot;false&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/system.web&amp;gt; &lt;br /&gt;
    &amp;lt;location path=&amp;quot;ActivePage.aspx&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;system.web&amp;gt;&lt;br /&gt;
        &amp;lt;pages enableViewState=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/system.web&amp;gt;&lt;br /&gt;
    &amp;lt;/location&amp;gt;   &lt;br /&gt;
  &amp;lt;/configuration&amp;gt;&lt;br /&gt;
=== Machine Level ===&lt;br /&gt;
To disable ViewState for all applications on a Web server, configure the &amp;lt;pages&amp;gt; element in the Machine.config file.&lt;br /&gt;
  &amp;lt;Machine.config &amp;gt;&lt;br /&gt;
      &amp;lt;system.web&amp;gt;&lt;br /&gt;
         &amp;lt;pages enableViewState=&amp;quot;true&amp;quot; /&amp;gt;           &lt;br /&gt;
      &amp;lt;/system.web&amp;gt;&lt;br /&gt;
  &amp;lt;/Machine.config&amp;gt;&lt;br /&gt;
== Saving and Restoring Values to and from the ViewState ==&lt;br /&gt;
We can add any object or Primitive types to ViewState by following statements:&lt;br /&gt;
    ViewState[&amp;quot;key&amp;quot;] = obj;&lt;br /&gt;
    //Some Code&lt;br /&gt;
    obj = ViewState[&amp;quot;key&amp;quot;];&lt;br /&gt;
== Performance Issues ==&lt;br /&gt;
For a better performance in page rendering the size of the ViewState for a page should be minima. Remember that the data in the ViewState makes a round trip and incurs more network bandwidth usage.  So, ViewState should always be used carefully.  For pages and controls that do not require a post back at all, set the EnableViewState property of the page or the control of the page to false.&lt;br /&gt;
'''Note''': that only controls contained within a &amp;lt;form runat=server&amp;gt; tag in the .aspx page can store ViewState&lt;br /&gt;
== Security Issues ==&lt;br /&gt;
For security measures (to ensure that the ViewState is not tampered) one of the following two measures can be adopted.&lt;br /&gt;
&lt;br /&gt;
* EnableViewStateMac property&lt;br /&gt;
* Encryption of ViewState content&lt;br /&gt;
&lt;br /&gt;
The EnableViewStateMac property ensures a Machine Authentication Check (MAC).  This should be set at the page level or in the application’s web.config file.  When set, this property appends a hash code to the ViewState before rendering.  Whenever a post back occurs, this hash code is recalculated and checked with the one that is stored in the __ViewState hidden field of the form.  It they do not match, the page is rejected, thus ensuring that the ViewState is not tampered.&lt;br /&gt;
&lt;br /&gt;
To encrypt the contents of the ViewState, use the following in the machine.config file.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;machineKey validation = &amp;quot;3Des&amp;quot; /&amp;gt;&lt;br /&gt;
        or&lt;br /&gt;
    &amp;lt; machineKey validation=&amp;quot;SHA1&amp;quot;/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=108</id>
		<title>State Management in ASP.NET</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=108"/>
		<updated>2020-01-23T13:30:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in the past.&lt;br /&gt;
&lt;br /&gt;
Stateless means, whenever we visit a website, our browser communicates with the respective server depending on our requested functionality or the request. In this case HTTP/HTTPs doesn't remember what website or URL we visited, or in other words we can say it doesn't hold the state of a previous website that we visited before closing our browser, that is called stateless.&lt;br /&gt;
&lt;br /&gt;
So our browsers are stateless.&lt;br /&gt;
&lt;br /&gt;
== State Management Types ==&lt;br /&gt;
[[File:State Management Techniques.png|none|State Management Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Client-side | Techniques ==&lt;br /&gt;
=== View State ===&lt;br /&gt;
View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.Please keep in mind though, that while cookies and sessions can be accessed from all your pages on your website, ViewState values are not carried between pages.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Points of ViewState:'''&lt;br /&gt;
* ViewState does not hold the controls, rather it holds the values of the form controls and their corresponding ID's that would otherwise be lost due to a post back because they do not post with the form.  &lt;br /&gt;
* ViewState is not used to hold session data or to transmit data between pages.&lt;br /&gt;
* ViewState does not recreate the dynamically created controls of a page.&lt;br /&gt;
* It does not restore the values to the controls after a post back operation.&lt;br /&gt;
* ViewState for a control is disabled, still the value would be retained after a post back of the page occurs, for input controls like TextBox or DropDownList.&lt;br /&gt;
  &lt;br /&gt;
So, ViewState represents the state of a page when it was last processed on the web server.  It holds the values of a control that has been dynamically changed.&lt;br /&gt;
&lt;br /&gt;
'''How does ViewState work?'''&lt;br /&gt;
&lt;br /&gt;
When the page is first created all controls are serialized to the ViewState, which is rendered as a hidden form field named __ViewState.  This hidden field corresponds to the server side object known as the ViewState.  ViewState for a page is stored as key-value pairs using the System.Web.UI.StateBag object.  When a post back occurs, the page de-serializes the ViewState and recreates all controls.  The ViewState for the controls in a page is stored as base 64 encoded strings in name - value pairs.  When a page is reloaded two methods pertaining to ViewState are called, namely the LoadViewState method and SaveViewState method.  The following is the content of the __ViewState hidden field as generated for a page in my system.&lt;br /&gt;
&lt;br /&gt;
[[File:ViewState.png|ViewState]]&lt;br /&gt;
&lt;br /&gt;
'''ViewState can be enabled and disabled in any of the following ways:'''&lt;br /&gt;
&lt;br /&gt;
* Control Level&lt;br /&gt;
* Page Level&lt;br /&gt;
* Application Level&lt;br /&gt;
* Machine Level&lt;br /&gt;
 &lt;br /&gt;
=== Hidden field ===&lt;br /&gt;
=== Cookies ===&lt;br /&gt;
=== Control State ===&lt;br /&gt;
=== Query Strings ===&lt;br /&gt;
== Server-side | Technique ==&lt;br /&gt;
=== Session State ===&lt;br /&gt;
==== InProc ====&lt;br /&gt;
==== OutProc ====&lt;br /&gt;
=== Application State ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=File:ViewState.png&amp;diff=107</id>
		<title>File:ViewState.png</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=File:ViewState.png&amp;diff=107"/>
		<updated>2020-01-23T13:29:57Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ViewState&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=106</id>
		<title>State Management in ASP.NET</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=State_Management_in_ASP.NET&amp;diff=106"/>
		<updated>2020-01-05T15:46:27Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in t...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As we all know, '''HTTP''' or '''HTTPS''' is stateless protocol. It just cleans up or we can say removes all the resources/references that were serving a specific request in the past.&lt;br /&gt;
&lt;br /&gt;
Stateless means, whenever we visit a website, our browser communicates with the respective server depending on our requested functionality or the request. In this case HTTP/HTTPs doesn't remember what website or URL we visited, or in other words we can say it doesn't hold the state of a previous website that we visited before closing our browser, that is called stateless.&lt;br /&gt;
&lt;br /&gt;
So our browsers are stateless.&lt;br /&gt;
&lt;br /&gt;
== State Management Types ==&lt;br /&gt;
[[File:State Management Techniques.png|none|State Management Techniques]]&lt;br /&gt;
&lt;br /&gt;
== Client-side | Techniques ==&lt;br /&gt;
=== View State ===&lt;br /&gt;
=== Hidden field ===&lt;br /&gt;
=== Cookies ===&lt;br /&gt;
=== Control State ===&lt;br /&gt;
=== Query Strings ===&lt;br /&gt;
== Server-side | Technique ==&lt;br /&gt;
=== Session State ===&lt;br /&gt;
==== InProc ====&lt;br /&gt;
==== OutProc ====&lt;br /&gt;
=== Application State ===&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=File:State_Management_Techniques.png&amp;diff=105</id>
		<title>File:State Management Techniques.png</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=File:State_Management_Techniques.png&amp;diff=105"/>
		<updated>2020-01-05T15:39:46Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;State Management Techniques&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=ASP.NET_page_life_cycle&amp;diff=104</id>
		<title>ASP.NET page life cycle</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=ASP.NET_page_life_cycle&amp;diff=104"/>
		<updated>2020-01-05T12:46:23Z</updated>

		<summary type="html">&lt;p&gt;Admin: Created page with &amp;quot;When an ASP.NET page runs, the page goes through a series of processing steps, which is know as page life cycle. These include initialization, instantiating controls, restorin...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When an ASP.NET page runs, the page goes through a series of processing steps, which is know as page life cycle. These include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering.&lt;br /&gt;
== Various stages or events of ASP.Net page life cycle ==&lt;br /&gt;
[[File:ASP.NET Page Life Cycle.png|frameless|ASP.NET Page Life Cycle]]&lt;br /&gt;
=== PreInit ===&lt;br /&gt;
* Check the IsPostBack property to determine whether this is the first time the page is being processed.&lt;br /&gt;
* Create or re-create dynamic controls.&lt;br /&gt;
* Set a master page dynamically.&lt;br /&gt;
* Set the Theme property dynamically.&lt;br /&gt;
'''Note''' : If the request is a postback then the values of the controls have not yet restored from the [[View State in ASP.NET|view state]]. If you set a control property at this stage, its value might be overwritten in the next event.&lt;br /&gt;
        protected void Page_PreInit(object sender, EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== Init ===&lt;br /&gt;
* This event fires after each control has been initialized.&lt;br /&gt;
* Each control's UniqueID is set and any skin settings have been applied.&lt;br /&gt;
* Use this event to read or initialize control properties.&lt;br /&gt;
* The &amp;quot;Init&amp;quot; event is fired first for the bottom-most control in the hierarchy, and then fired up the hierarchy until it is fired for the page itself.&lt;br /&gt;
        protected void Page_Init(object sender, EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== InitComplete ===&lt;br /&gt;
* Until now the viewstate values are not yet loaded, hence you can use this event to make changes to the view state that you want to ensure are persisted after the next postback.&lt;br /&gt;
* Raised by the Page object.&lt;br /&gt;
* Use this event for processing tasks that require all initialization to be complete.&lt;br /&gt;
        protected void Page_InitComplete(object sender, EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== OnPreLoad ===&lt;br /&gt;
* Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance.&lt;br /&gt;
* Before the Page instance raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.&lt;br /&gt;
* Loads ViewState: ViewState data are loaded to controls.&lt;br /&gt;
* Loads Postback data: Postback data are now handed to the page controls.&lt;br /&gt;
        protected override void OnPreLoad(EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== Load ===&lt;br /&gt;
* The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page.&lt;br /&gt;
* This is the first place in the page lifecycle that all values are restored.&lt;br /&gt;
* Most code checks the value of IsPostBack to avoid unnecessarily resetting state.&lt;br /&gt;
* You may also call Validate and check the value of IsValid in this method.&lt;br /&gt;
* You can also create dynamic controls in this method.&lt;br /&gt;
* Use the OnLoad event method to set properties in controls and establish database connections.&lt;br /&gt;
        protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== PostBack Event(s) ===&lt;br /&gt;
* ASP.NET now calls any events on the page or its controls that caused the PostBack to occur.&lt;br /&gt;
* Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.&lt;br /&gt;
* In a postback request, if the page contains validator controls, check the IsValid property of the Page and of individual validation controls before performing any processing.&lt;br /&gt;
* This is just an example of a control event. Here it is the button click event that caused the postback.&lt;br /&gt;
        protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== LoadComplete ===&lt;br /&gt;
* Raised at the end of the event-handling stage.&lt;br /&gt;
* Use this event for tasks that require that all other controls on the page be loaded.&lt;br /&gt;
        protected void Page_LoadComplete(object sender, EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== OnPreRender ===&lt;br /&gt;
* Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls.&lt;br /&gt;
* The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. The PreRender event of individual controls occurs after the PreRender event of the page.&lt;br /&gt;
* The PreRender event of individual controls occurs after the PreRender event of the page.&lt;br /&gt;
* Allows final changes to the page or its control.&lt;br /&gt;
* This event takes place before saving ViewState, so any changes made here are saved.&lt;br /&gt;
* For example: After this event, you cannot change any property of a button or change any viewstate value.&lt;br /&gt;
* Each data bound control whose DataSourceID property is set calls its DataBind method.&lt;br /&gt;
* Use the event to make final changes to the contents of the page or its controls.&lt;br /&gt;
        protected override void OnPreRender(EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
=== OnSaveStateComplete ===&lt;br /&gt;
* Raised after view state and control state have been saved for the page and for all controls.&lt;br /&gt;
* Before this event occurs, ViewState has been saved for the page and for all controls.&lt;br /&gt;
* Any changes to the page or controls at this point will be ignored.&lt;br /&gt;
* Use this event perform tasks that require the view state to be saved, but that do not make any changes to controls.&lt;br /&gt;
        protected override void OnSaveStateComplete(EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
=== Render Method ===&lt;br /&gt;
* This is a method of the page object and its controls (and not an event).&lt;br /&gt;
* The Render method generates the client-side HTML, Dynamic Hypertext Markup Language (DHTML), and script that are necessary to properly display a control at the browser.&lt;br /&gt;
=== UnLoad ===&lt;br /&gt;
* This event is used for cleanup code.&lt;br /&gt;
* At this point, all processing has occurred and it is safe to dispose of any remaining objects, including the Page object.&lt;br /&gt;
* Cleanup can be performed on:&lt;br /&gt;
# Instances of classes, in other words objects&lt;br /&gt;
# Closing opened files&lt;br /&gt;
# Closing database connections.&lt;br /&gt;
* This event occurs for each control and then for the page.&lt;br /&gt;
* During the unload stage, the page and its controls have been rendered, so you cannot make further changes to the response stream.&lt;br /&gt;
* If you attempt to call a method such as the Response.Write method then the page will throw an exception.&lt;br /&gt;
        protected void Page_UnLoad(object sender, EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=File:ASP.NET_Page_Life_Cycle.png&amp;diff=102</id>
		<title>File:ASP.NET Page Life Cycle.png</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=File:ASP.NET_Page_Life_Cycle.png&amp;diff=102"/>
		<updated>2020-01-05T11:57:26Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ASP.NET Page Life Cycle&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://jholjhapata.com/index.php?title=Constructor&amp;diff=101</id>
		<title>Constructor</title>
		<link rel="alternate" type="text/html" href="https://jholjhapata.com/index.php?title=Constructor&amp;diff=101"/>
		<updated>2020-01-05T08:31:52Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''constructor''' is a special method of the class which gets automatically invoked whenever an instance of the class is created. Like methods, a constructor also contains the collection of instructions that are executed at the time of Object creation. It is used to assign initial values to the data members of the same class.&lt;br /&gt;
&lt;br /&gt;
    class Software&lt;br /&gt;
    {&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public Software() { }&lt;br /&gt;
        // Some Code........        &lt;br /&gt;
    }&lt;br /&gt;
    // an object is created of Software class,&lt;br /&gt;
    // So above constructor is called&lt;br /&gt;
    Software sw = new Software();&lt;br /&gt;
&lt;br /&gt;
== Points About Constructors ==&lt;br /&gt;
# Constructor of a class must have the same name as the class name in which it resides.&lt;br /&gt;
# A constructor can not be abstract, final, static and Synchronized.&lt;br /&gt;
# Within a class, you can create only one static constructor.&lt;br /&gt;
# A constructor doesn’t have any return type, not even void.&lt;br /&gt;
# A static constructor cannot be a parameterized constructor.&lt;br /&gt;
# A class can have any number of constructors.&lt;br /&gt;
# Access modifiers can be used in constructor declaration to control its access i.e which other class can call the constructor.&lt;br /&gt;
== Different between Constructors and Method ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Constructor !! Method&lt;br /&gt;
|-&lt;br /&gt;
| A constructor is used to initialize an object || A method is used to expose the behavior of an object&lt;br /&gt;
|-&lt;br /&gt;
| The constructor must not have a return type || The method has or not have a return type&lt;br /&gt;
|-&lt;br /&gt;
| A constructor must be the same as the class name || Method name may or may not be same as the class name&lt;br /&gt;
|-&lt;br /&gt;
| A constructor is invoked implicitly || A method is invoked explicitly&lt;br /&gt;
|}&lt;br /&gt;
== Types of Constructor ==&lt;br /&gt;
=== Default Constructor ===&lt;br /&gt;
A constructor without any parameters is called a default constructor. If we do not create constructor the class will automatically call default constructor when an object is created.&lt;br /&gt;
    public class User&lt;br /&gt;
    {&lt;br /&gt;
        public string firstName;&lt;br /&gt;
        public string lastName;&lt;br /&gt;
        public User()&lt;br /&gt;
        {&lt;br /&gt;
            firstName = &amp;quot;Soumya&amp;quot;;&lt;br /&gt;
            lastName = &amp;quot;Das&amp;quot;;&lt;br /&gt;
        }&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;
            User user = new User();&lt;br /&gt;
            Console.WriteLine(&amp;quot;Full Name:&amp;quot; + user.firstName + &amp;quot; &amp;quot; + user.lastName);&lt;br /&gt;
            Console.ReadLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
=== Parametrized Constructor ===&lt;br /&gt;
A constructor with at least one parameter is called a parametrized constructor.&lt;br /&gt;
    public class User&lt;br /&gt;
    {&lt;br /&gt;
        public string firstName;&lt;br /&gt;
        public string lastName;&lt;br /&gt;
        public User(string firstName, string lastName)&lt;br /&gt;
        {&lt;br /&gt;
            this.firstName = firstName;&lt;br /&gt;
            this.lastName = lastName;&lt;br /&gt;
        }&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;
            User user = new User(&amp;quot;Soumya&amp;quot;,&amp;quot;Das&amp;quot;);&lt;br /&gt;
            Console.WriteLine(&amp;quot;Full Name:&amp;quot; + user.firstName + &amp;quot; &amp;quot; + user.lastName);&lt;br /&gt;
            Console.ReadLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
=== Copy Constructor ===&lt;br /&gt;
The constructor which creates an object by copying variables from another object is called a copy constructor.&lt;br /&gt;
    public class User&lt;br /&gt;
    {&lt;br /&gt;
        public string firstName;&lt;br /&gt;
        public string lastName;&lt;br /&gt;
        public User()&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
        public User(User user)&lt;br /&gt;
        {&lt;br /&gt;
            this.firstName = user.firstName;&lt;br /&gt;
            this.lastName = user.lastName;&lt;br /&gt;
        }&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;
            User user = new User();&lt;br /&gt;
            user.firstName = &amp;quot;Soumya&amp;quot;;&lt;br /&gt;
            user.lastName = &amp;quot;Das&amp;quot;;&lt;br /&gt;
            User user1 = new User(user);&lt;br /&gt;
            Console.WriteLine(&amp;quot;Full Name:&amp;quot; + user.firstName + &amp;quot; &amp;quot; + user.lastName);&lt;br /&gt;
            Console.ReadLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
=== Private Constructor ===&lt;br /&gt;
A private constructor is a special instance constructor. It is generally used in classes that contain static members only. If a class has one or more private constructors and no public constructors, other classes (except nested classes) cannot create instances of this class. The use of private constructor is to serve [[Singleton Design Pattern]].&lt;br /&gt;
* One use of private constructor is when we have the only static member.&lt;br /&gt;
* It provides the implementation of [[Singleton Design Pattern]].&lt;br /&gt;
* Once we provide constructor (private/public/any) the compiler will not add the no parameter public constructor to any class.&lt;br /&gt;
   class Program&lt;br /&gt;
   {&lt;br /&gt;
       static void Main(string[] args)&lt;br /&gt;
       {&lt;br /&gt;
           SingleTon obj1 = SingleTon.getInstance;&lt;br /&gt;
           obj1.printText(&amp;quot;obj1&amp;quot;);&lt;br /&gt;
           SingleTon obj2 = SingleTon.getInstance;&lt;br /&gt;
           obj2.printText(&amp;quot;obj2&amp;quot;);&lt;br /&gt;
           Console.WriteLine(&amp;quot;Main End&amp;quot;);&lt;br /&gt;
           Console.ReadLine();&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
   class SingleTon&lt;br /&gt;
   {&lt;br /&gt;
       private static int objectCounter = 0;&lt;br /&gt;
       private static SingleTon instance;&lt;br /&gt;
       private SingleTon()&lt;br /&gt;
       {&lt;br /&gt;
           objectCounter++;&lt;br /&gt;
           Console.WriteLine(&amp;quot;objectCounter : &amp;quot; + objectCounter.ToString());&lt;br /&gt;
       }&lt;br /&gt;
       public static SingleTon getInstance&lt;br /&gt;
       {&lt;br /&gt;
           get&lt;br /&gt;
           {&lt;br /&gt;
               if(instance == null)&lt;br /&gt;
                   instance = new SingleTon();&lt;br /&gt;
               return instance;&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
       public void printText(string strData)&lt;br /&gt;
       {&lt;br /&gt;
           Console.WriteLine(strData);&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
=== Static Constructor ===&lt;br /&gt;
A static constructor is used to initialize any static data, or to perform a particular action that needs to be performed once only. It is called automatically before the first instance is created or any static members are referenced.&lt;br /&gt;
==== Static Constructor Characteristic ====&lt;br /&gt;
* A static constructor does not take any access modifiers.&lt;br /&gt;
* A static constructor does not have a parameter.&lt;br /&gt;
* A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.&lt;br /&gt;
* A static constructor cannot be called directly.&lt;br /&gt;
* The user has no control over when the static constructor is executed in the program.&lt;br /&gt;
* A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.&lt;br /&gt;
* A class can have only one static constructor.&lt;br /&gt;
* It can access only static members of a class.&lt;br /&gt;
    public class User&lt;br /&gt;
    {&lt;br /&gt;
        public string firstName;&lt;br /&gt;
        public string lastName;&lt;br /&gt;
        public static string location;&lt;br /&gt;
        public User()&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
        static User()&lt;br /&gt;
        {&lt;br /&gt;
            location = &amp;quot;India&amp;quot;;&lt;br /&gt;
        }&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;
            &lt;br /&gt;
            Console.WriteLine(&amp;quot;Static variable:&amp;quot; + User.location);&lt;br /&gt;
            Console.ReadLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
</feed>