Application of .NET Technology Unit 03 C Sharp Using Libraries Notes Set 01

Download Computer Science Useful Resources

Access comprehensive study materials and useful resources for .NET Technology using the Application of .NET Technology Unit 03 C Sharp Using Libraries Notes Set 01. Designed to align with the 2026-27 academic guidelines, these advanced resources help Computer Science students reinforce core concepts beyond standard textbooks.

Access Study Guides and Summaries

View or download the dedicated Application of .NET Technology Unit 03 C Sharp Using Libraries Notes Set 01 resource below. Engaging with these advanced study guides under focused conditions ensures continuous academic progress and mastery of the 2026-27 curriculum for .NET Technology.

This page covers the C# library topics of the course: namespaces and the System namespace, stream based input and output with FileStream, StreamReader and StreamWriter, and threading with its life cycle. It then goes on to sockets, HTTP and FTP programming, the LINQ standard query operators, Windows Forms and the ASP.NET web application model, ending with error handling.

Namespace Systems

Namespaces are C# program elements designed to help you organize your programs. They also provide assistance in avoiding name clashes between two sets of code. Implementing Namespaces in your own code is a good habit because it is likely to save you from problems later when you want to reuse some of your code.

For example, if you created a class named Console, you would need to put it in your own namespace to ensure that there wasn't any confusion about when the System.Console class should be used or when your class should be used.

Functionality provided by System namespace

The C# library System provides a list of different functionalities for namespaces, listed here:

1. Commonly used value,
2. Mathematics,
3. Remote and local program invocation,
4. Application environment management,
5. Reference data types,
6. Events and event handlers,
7. Interfaces, attributes, processing exceptions,
8. Data type conversion,
9. Method parameter manipulation.

Classes provided by System namespace

Along with different functionalities, namespaces in C# provide a list of classes, listed here:

1. AccessViolationException,
2. Array,
3. ArgumentNullException,
4. AttributeUsageAttribute,
5. Buffer,
6. Console,
7. Convert,
8. Delegate,
9. Exception,
10. InvalidCastException.

Interfaces provided by System namespace

A few interfaces provided by the namespace System in C# are listed here:

1. Public interface ICloneable.
2. Public interface IComparable.
3. Public interface IComparable<T>.
4. Public interface IConvertible.
5. Public interface ICustomFormatter.
6. Public interface IDisposable.
7. Public interface IEquatable<T>.
8. Public interface IFormatProvider.

Namespaces

A namespace is designed for providing a way to keep one set of names separate from another. The class names declared in one namespace will not conflict with the same class names declared in another.

1. Defining a namespace,
2. The using keyword,
3. Nested namespaces.

Defining a Namespace

A namespace definition begins with the keyword namespace followed by the namespace name as follows:

namespace namespace_name
{
   // code declarations
}

To call the namespace-enabled version of either function or variable, prepend the namespace name as follows:

namespace_name.item_name;

The using Keyword

using System;
namespace first_space

The using keyword states that the program is using the names in the given namespace. For example, we are using the System namespace in our programs. The class Console is defined there. We just write:

Console.WriteLine ("Hello there");

We could have written the fully qualified name as:

System.Console.WriteLine("Hello there");

With the using namespace directive, the compiler is told that the subsequent code is making use of names in the specified namespace.

Nested Namespaces

Namespaces can be nested, where you can define one namespace inside another namespace as follows:

namespace namespace_name1
{
   // code declarations
   namespace namespace_name2
   {
      // code declarations
   }
}

You can access members of a nested namespace by using the dot (.) operator. Namespaces can hold other types as follows:

1. Classes,
2. Structures,
3. Interfaces,
4. Enumerations and
5. Delegates.

Input Output

The input and output in C# is based on streams. A stream is an abstraction of a sequence of bytes, such as a file, an input/output device, an inter-process communication pipe, or a TCP/IP socket. Streams transfer data from one point to another point. Streams are also capable of manipulating the data; for example they can compress or encrypt the data.

In the .NET Framework, the System.IO namespaces contain types that enable reading and writing on data streams and files.

C# I/O Classes

The System.IO namespace has various classes that are used for performing various operations with files, like creating and deleting files, reading from or writing to a file, closing a file etc. The following table shows some commonly used non-abstract classes in the System.IO namespace:

I/O ClassDescription
BinaryReaderReads primitive data from a binary stream.
BinaryWriterWrites primitive data in binary format.
BufferedStreamA temporary storage for a stream of bytes.
DirectoryHelps in manipulating a directory structure.
DirectoryInfoUsed for performing operations on directories.
DriveInfoProvides information for the drives.
FileHelps in manipulating files.
FileInfoUsed for performing operations on files.
FileStreamUsed to read from and write to any location in a file.
MemoryStreamUsed for random access to streamed data stored in memory.
PathPerforms operations on path information.
StreamReaderUsed for reading characters from a byte stream.
StreamWriterIs used for writing characters to a stream.
StringReaderIs used for reading from a string buffer.
StringWriterIs used for writing into a string buffer.

The FileStream Class

The FileStream class in the System.IO namespace helps in reading from, writing to and closing files. This class derives from the abstract class Stream. You need to create a FileStream object to create a new file or open an existing file. The syntax for creating a FileStream object is as follows:

FileStream <object_name> = new FileStream( <file_name>, <FileMode Enumerator>,
   <FileAccess Enumerator>, <FileShare Enumerator>);

The following program demonstrates use of the FileStream class:

using System;
using System.IO;

namespace FileIOApplication
{
   class Program
   {
      static void Main(string[] args)
      {
         FileStream F = new FileStream("test.dat", FileMode.OpenOrCreate,
            FileAccess.ReadWrite);
         for (int i = 1; i <= 20; i++)
         {
            F.WriteByte((byte)i);
         }

         F.Position = 0;
         for (int i = 0; i <= 20; i++)
         {
            Console.Write(F.ReadByte() + " ");
         }
         F.Close();
         Console.ReadKey();
      }
   }
}

When the above code is compiled and executed, it produces the following result:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -1

Reading from and Writing into Text files

The StreamReader and StreamWriter classes are used for reading from and writing data to text files. These classes inherit from the abstract base class Stream, which supports reading and writing bytes into a file stream.

The StreamReader Class

The StreamReader class also inherits from the abstract base class TextReader that represents a reader for reading series of characters. The following table describes some of the commonly used methods of the StreamReader class:

MethodDescription
public override void Close()It closes the StreamReader object and the underlying stream, and releases any system resources associated with the reader.
public override int Peek()Returns the next available character but does not consume it.
public override int Read()Reads the next character from the input stream and advances the character position by one character.

The StreamWriter Class

When the above code is compiled and executed, it produces the following result:

Zara Ali
Nuha Ali

The following table describes some of the commonly used methods of the StreamWriter class:

No.MethodDescription
1public override void Close()Closes the current StreamWriter object and the underlying stream.
2public override void Flush()Clears all buffers for the current writer and causes any buffered data to be written to the underlying stream.
3public virtual void Write(bool value)Writes the text representation of a Boolean value to the text string or stream. (Inherited from TextWriter.)
4public override void Write( char value )Writes a character to the stream.
5public virtual void Write( decimal value )Writes the text representation of a decimal value to the text string or stream.
6public virtual void Write( double value )Writes the text representation of an 8-byte floating-point value to the text string or stream.
7public virtual void Write( int value )Writes the text representation of a 4-byte signed integer to the text string or stream.
8public override void Write( string value )Writes a string to the stream.
9public virtual void WriteLine()Writes a line terminator to the text string or stream.

Multithreading

A thread is defined as the execution path of a program. Each thread defines a unique flow of control. If your application involves complicated and time consuming operations then it is often helpful to set different execution paths or threads, with each thread performing a particular job.

Threads are lightweight processes. One common example of use of thread is implementation of concurrent programming by modern operating systems. Use of threads saves wastage of CPU cycle and increase efficiency of an application.

However, this way the application can perform one job at a time. To make it execute more than one task at a time, it could be divided into smaller threads.

Thread Life Cycle

The life cycle of a thread starts when an object of the System.Threading.Thread class is created and ends when the thread is terminated or completes execution. The various states in the life cycle of a thread:

The Unstarted State: It is the situation when the instance of the thread is created but the Start method has not been called.

The Ready State: It is the situation when the thread is ready to run and waiting CPU cycle.

The Not Runnable State: A thread is not runnable, when:

1. Sleep method has been called,
2. Wait method has been called,
3. Blocked by I/O operations.

The Dead State: It is the situation when the thread has completed execution or has been aborted.

The Main Thread

When a C# program starts execution, the main thread is automatically created. The threads created using the Thread class are called the child threads of the main thread. You can access a thread using the CurrentThread property of the Thread class.

using System;
using System.Threading;

namespace MultithreadingApplication
{
   class MainThreadProgram
   {
      static void Main(string[] args)
      {
         Thread th = Thread.CurrentThread;
         th.Name = "MainThread";
         Console.WriteLine("This is {0}", th.Name);
         Console.ReadKey();
      }
   }
}

When the above code is compiled and executed, it produces the following result:

This is MainThread

In C#, the System.Threading.Thread class is used for working with threads. It allows creating and accessing individual threads in a multithreaded application. The first thread to be executed in a process is called the main thread.

Creating Threads

The following program demonstrates the concept:

using System;
using System.Threading;
namespace MultithreadingApplication
{
   class ThreadCreationProgram
   {
      public static void CallToChildThread()
      {
         Console.WriteLine("Child thread starts");
      }
      static void Main(string[] args)
      {
         ThreadStart childref = new ThreadStart(CallToChildThread);
         Console.WriteLine("In Main: Creating the Child thread");
         Thread childThread = new Thread(childref);
         childThread.Start();
         Console.ReadKey();
      }
   }
}

When the code is compiled and executed, it produces the following result:

In Main: Creating the Child thread
Child thread starts

Threads are created by extending the Thread class. The extended Thread class then calls the Start() method to begin the child thread execution.

Managing Threads

The Thread class provides various methods for managing threads. The following example demonstrates the use of the Sleep() method for making a thread pause for a specific period of time.

using System;
using System.Threading;
namespace MultithreadingApplication
{
   class ThreadCreationProgram
   {
      public static void CallToChildThread()
      {
         Console.WriteLine("Child thread starts");
         // the thread is paused for 5000 milliseconds
         int sleepfor = 5000;
         Console.WriteLine("Child Thread Paused for {0} seconds",
            sleepfor / 1000);
         Thread.Sleep(sleepfor);
         Console.WriteLine("Child thread resumes");
      }
      static void Main(string[] args)
      {
         ThreadStart childref = new ThreadStart(CallToChildThread);
         Console.WriteLine("In Main: Creating the Child thread");
         Thread childThread = new Thread(childref);
         childThread.Start();
         Console.ReadKey();
      }
   }
}

When the code is compiled and executed, it produces the following result:

In Main: Creating the Child thread
Child thread starts
Child Thread Paused for 5 seconds
Child thread resumes

Destroying Threads

The Abort() method is used for destroying threads. The runtime aborts the thread by throwing a ThreadAbortException. This exception cannot be caught; the control is sent to the finally block, if any.

Networking and Sockets

C# language has access to an entire suite of networking libraries. Some of the capabilities range from low-level socket connections to wrapped HTTP classes.

1. Implementing Sockets,
2. A Socket Server,
3. A Socket Client,
4. Working with HTTP,
5. Performing FTP File Transfers,
6. Sending SMTP Mail.

This server program instantiates a List<string>, talk, and initializes it with quote strings during constructor processing.

using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
class MoneyServer
{
   static void Main()
   {
      const int StreamSize = 256;
      const int Port = 2010;
      var ipAddr = new IPAddress(
         new byte[] { 127, 0, 0, 1 });
      var talk = new List<string>
      {
         "A penny saved is too small, make it a buck.",
         "Keep your wooden nickel. It'll be worth something someday.",
         "It's your dime, but you're better off dialing 10-10-XXX."
      };
      var mSvr = new MoneyServer();
      var AsciiEnc = new ASCIIEncoding();
      var inStream = new byte[StreamSize];
      var outStream = new byte[StreamSize];
      Random rnd = null;
      string reqString = string.Empty;
      int index = 0;
      var tcpl = new TcpListener(ipAddr, Port);
      tcpl.Start();
      Console.WriteLine("Server is Running...");
      do
      {
         try
         {
            Socket sock = tcpl.AcceptSocket();
            int count = sock.Receive(inStream, inStream.Length, 0);
            reqString = AsciiEnc.GetString(inStream, 0, count);
            Console.WriteLine(reqString);
            rnd = new Random();
            index = rnd.Next(talk.Count);
            outStream = AsciiEnc.GetBytes(talk[index] as string);
            sock.Send(outStream, outStream.Length, 0);
         }
         catch (SocketException sockEx)
         {
            Console.WriteLine("Generic Exception Message: {0}", sockEx.ToString());
         }
      } while (reqString != "bye");
      tcpl.Stop();
   }
}

The real action for this program starts in the Main method. Socket operations are encapsulated in the TCP classes. This program uses the TcpListener class to create a socket connection on the local host. The example accepts a single parameter, indicating the port number. After the TcpListener class is instantiated, it must be started with the Start method.

The client program uses sockets to request information from a server. It makes a socket connection, sends a request, and receives a reply.

Working with HTTP

HTTP is what enables communication across the Web.

using System;
using System.IO;
using System.Net;
using System.Text;
namespace HttpRequestDemo
{
   class Program
   {
      static void Main()
      {
         const int BufferSize = 2048;
         try
         {
            var AsciiEnc = new ASCIIEncoding();
            var buf = new byte[BufferSize];
            HttpWebRequest httpReq =
               WebRequest.Create(
               "http://www.csharp-station.com")
               as HttpWebRequest;
            HttpWebResponse httpResp =
               httpReq.GetResponse() as HttpWebResponse;
            Stream httpStream = httpResp.GetResponseStream();
            int count = httpStream.Read(buf, 0, buf.Length);
            Console.WriteLine(
               AsciiEnc.GetString(buf, 0, count));
         }
         catch (Exception e)
         {
            Console.WriteLine("Generic Exception: {0}",
               e.Message);
         }
      }
   }
}

Knowing how to request a web page can be useful for caching or screen scraping, which is a good application of regular expressions. The Create method accepts a string representation of an URL. Here's the statement.

HttpWebRequest httpReq =
   WebRequest.Create(
   "http://www.csharp-station.com")
   as HttpWebRequest;

After an HttpWebRequest object is created, it can be used to obtain an HttpWebResponse object. This happens by invoking its GetResponse method, which returns a WebResponse object. The WebResponse object is an abstract base class of the HttpWebResponse class, and a cast operation is necessary for conversion.

Performing FTP File Transfers

Another Internet protocol for moving files around is FTP, which is supported by the .NET FCL. The following sections show you how to get and put files with FTP.

Putting Files on an FTP Server

To upload files to an FTP server, you need to create an FtpWebRequest object, get a stream reference to where you want to put the file, and write the file to the stream.

Getting Files from an FTP Server

To get a file from an FTP server, you need to create the FtpWebRequest, open the stream to the file, read the bytes, open the stream to the file you need to create, and write the bytes to the new file.

FTP servers require some type of credentials, even if it is anonymous access with a username of "anonymous" and a password that consists of your email address. The rest of the code uses using statements to open the response stream, read bytes from the FTP server, open a file stream to the new file, and then write those bytes to the new file. Remember that the using statements are essential because they close the file streams for you.

Data Handling Logic

1. Customizing Insert, Update, and Delete with Partial Methods.
2. Customizing Property Changes with Partial Methods.

Extend the logic of your system by providing an implementation for any of these partial methods. The following example shows how to detect a property change for the Position property of the HospitalStaff entity.

public partial class HospitalStaff
{
   partial void OnPositionChanging(string value)
   {
      if (Position != null && Position != value)
      {
         throw new ArgumentException("Can't change Position.");
      }
   }
}

Standard Query Operators

The following sections provide a quick overview of available query operators, some with C# aliases and others without, for reference, and give a simple example in each category so that you can see how they are used.

1. Sorting Operators
2. Set Operators
3. Filtering Operators
4. Quantifier Operators
5. Projection Operators
6. Partitioning Operators
7. Join Operators
8. Grouping Operators
9. Generation Operators
10. Equality Operators

Sorting Operators

Sorting operations affect the ordering of the results.

OperatorDescription
OrderBySets sort order.
OrderByDescendingSorts in descending order.
ThenBySubsequent sorts.
ThenByDescendingSubsequent sorts in descending order.
ReverseReverses results.

Set Operators

Set operators are for set-based operations.

OperatorDescription
DistinctReturns unique values.
ExceptLike a SQL left join, returns results from one set that aren't in another.
IntersectReturns common elements from each set.
UnionReturns all objects from both sets.

Filtering Operators

Filtering operators return a subset of a collection.

OperatorDescription
OfTypeObjects of the specified type.
whereObjects meeting specified predicate.

The C# where clause aliases the where operator, but there isn't an alias for the OfType operator. You could give where a predicate, such as where staff.GetType() == typeof(TempStaffMember). TempStaffMember is a class that derives from StaffMember.

Projection Operators

Projection operators alter the shape of query results. If a projection operator alters the shape, a projection, the results may contain more or fewer fields or perform some manipulation of an existing field for the result set.

OperatorDescription
SelectDefines the fields/properties to return.
SelectManyFlattens a multilevel hierarchy to access results.

Partitioning Operators

Partitioning operators specify which group of records you want from a collection.

OperatorDescription
SkipSkips over a specified number of records.
SkipWhileSkips over records while the specified condition is true.
TakeTakes the specified number of records.
TakeWhileTakes records while the specified condition is true.

A common scenario for the partitioning operators is to facilitate paging. In many cases, the number of records in a record set is too large to hold in memory, so you want to bring in only the minimum number necessary.

Join Operators

Join operators enable you to combine sets of data.

OperatorDescription
JoinReturns set of records where keys in two sets are equal.
GroupJoinBuilds a hierarchy of objects based on child record set keys that match a parent key.

Here's an example of a GroupJoin so that you can see the operator syntax:

Grouping Operators

A grouping operator allows you to create groups of data.

OperatorDescription
GroupByGroups the elements of a collection by a specified key.
ToLookupCreates an ILookup dictionary of lists with specified key.

Equality Operators

There is only one equality operator, which tells you whether two collections are equal.

OperatorDescription
SequenceEqualReturns true if two collections are equal.

Element Operators

To return just one record from a collection, you can use an element operator.

OperatorDescription
ElementAtReturns the element at a specified position.
ElementAtOrDefaultSame as ElementAt, but returns the default value of type if not found.
FirstReturns the first element in results.
FirstOrDefaultSame as First, but returns the default value of type if not found.
LastReturns the last element in results.
LastOrDefaultSame as Last, but returns the default value of type if not found.
SingleReturns only element in results.
SingleOrDefaultSame as Single, but returns the default value of type if not found.

Each element operator has a version that returns a default value. The difference is that if you invoke an element operator that isn't a default version and the collection doesn't have that value, you'll get an InvalidOperationException exception.

Conversion Operators

A conversion operator allows you to transform results from one type or collection to another.

OperatorDescription
AsEnumerableConverts to IEnumerable<T>.
AsQueryableConverts to IQueryable<T>.
CastConverts weakly typed collection (for example, ArrayList) to IEnumerable<T>.
OfTypeFilters collection based on type.
ToArrayConverts to an array.
ToDictionaryConverts to a Dictionary.
ToListConverts to a list.
ToLookupConverts to a lookup.

Concatenation Operator

There is one concatenation operator, and it allows you to concatenate one collection to another.

OperatorDescription
ConcatConcatenates one collection to another to form a single collection.

Aggregate Operators

An aggregate operator will perform a computation on a group of values and provide a single result.

OperatorDescription
AggregateCreates a custom aggregation.
AverageReturns an average.
CountReturns the number of items in a collection of size int.MaxValue or less.
LongCountReturns the number of items in a large collection up to size long.MaxValue.
MaxReturns the max item.
MinReturns the min item.
SumReturns the sum of all items.

Windows Forms Fundamentals

To get started, create a new Windows Forms application named WinFormFundamentals. You can do this in VS2008 by creating a new project and selecting Windows Forms Application, or right-click an existing Solution file and select Windows Forms Application.

The result is a new project with references to System.Windows.Forms.dll, which is the library holding the Windows Forms API. A form is a class, just like any other type you write C# code against.

using System.Windows.Forms;
class SimpleForm : Form
{
   static void Main()
   {
      Application.Run(
         new SimpleForm());
   }
   public SimpleForm()
   {
      var warnBtn =
         new Button
         {
            Text = "Don't Click Me!",
            Width = 150,
            Height = 50,
            Left = ClientRectangle.Width/2 - 75,
            Top = ClientRectangle.Height/2 - 25
         };
      warnBtn.Click +=
         (sender, evtArgs) => MessageBox.Show(
            "I thought I told you not to click!");
      Controls.Add(warnBtn);
   }
}

When the above code is compiled and executed, it shows a form with a single button labelled Don't Click Me!. All controls on the form are also classes, and you use them just like any other type in C#. Windows Forms is a classic example of the effective implementation and use of delegates and events.

The .NET Framework Class Library - Windows Forms API

You have the Windows Forms API that belongs to the .NET Framework Class Library that exposes events. Then you use the delegates that those events are based on to connect your code to the API to make your program work.

Support for Windows Forms

1. The Visual Design Environment.
2. Files in a Windows Forms Application.
3. The Windows Forms Entry Point.
4. User Code.
5. Visual Designer-Generated Code.
6. Modifying the Visual Designer.
7. Using Windows Forms Controls.

The Visual Design Environment

Visual Studio has a helpful visual design environment that helps you build user interfaces with ease; it contains controls that you can drag and drop onto the design surface. The design surface is in the middle of the screen. You can see that it is a WYSIWYG environment, where you can resize the form and visually see the results of your work.

Nonvisual controls appear below the form in the visual designer in an area called the component tray. You've seen the Solution Explorer already when building console applications, and it is a necessary part of every application.

The Properties window is context-sensitive. It will change, depending on which window or control is selected on the design surface. In such cases, you must use the drop-down window at the top of the Properties window to select the control.

Files in a Windows Forms Application

There are a few different files that were created by the Windows Application Project Wizard.

FilePurpose
Form1.csUser code for working with the form. You normally work in this file most of the time. All your event handlers and code that call your business logic are added here.
Form1.Designer.csVisual Designer-generated code. You normally don't ever need to open this file. If you need to write your own code to work with the form, it will typically be done through Form1.cs.
Form1.resxResource file for bitmaps, strings, icons, and so on. Localizing and globalization discusses resource files in greater depth.
Program.csContains the Main method.

The Windows Forms Entry Point

If you open the Program.cs file, you'll see a Main method. This is much like you've seen in console applications, whose entry point is also the Main method. The Application.Run method will start the program and not return until the application closes.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Chapter_25
{
   static class Program
   {
      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main()
      {
         // other code omitted
         Application.Run(new Form1());
      }
   }
}

User Code

When adding specific behavior to a Windows Forms application, you'll use the Form1.cs class, which the Windows application project creates for you. You can see this code by right-clicking either the form in the Visual Designer or Form1.cs in Solution Explorer and selecting View Code. There are a couple of significant observations to make at this point. First, Form1 is a partial class.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Chapter_25
{
   public partial class Form1 : Form
   {
      public Form1()
      {
         InitializeComponent();
      }
   }
}

Visual Designer-Generated Code

Form1.Designer.cs holds the matching partial to the Form1 partial class defined in Form1.cs. When this code is compiled, C# combines these two files into a single class definition. Form1 is a partial class and its constructor calls an InitializeComponent method; the definition of the InitializeComponent method is in the other Form1 partial class.

When Modifying the Visual Designer

This will demonstrate to you how the Form1.cs and Form1.Designer.cs files work together while you are building a UI, and the reason for the contents of each file.

1. Drag and drop a Button control onto the design surface.
2. If you want to delete anything that you accidentally drop on the design surface, select the control and press the Delete key or right-click the control and select Delete.
3. Go to the Properties window and set the following properties. (You can find Height and Width under Size.)
4. Set Text to Don't Click Me!.
5. Set Height to 50.
6. Set Width to 150.
7. Set (Name) to btnWarn.

Using Windows Forms Controls

A control is a specialized window with specific features and a unique purpose. These are things like Button, CheckBox, CheckedListBox, ComboBox, DataGridView, DateTimePicker, Form, GroupBox, Label, LinkLabel, ListBox, ListView etc.

ControlDescription
ButtonA control that can be clicked to perform some desired action.
CheckBoxPrimarily used for displaying a binary state of an object. Clicking the check box causes it to toggle between a checked or unchecked state.
CheckedListBoxList box with a column of check boxes.
ComboBoxA drop-down list of choices that operates similar to the list box. The primary difference is that the combo box is more compact and efficient with screen real estate.

The Web Application Model

When writing for the web, you need to understand where code resides and executes. An ASP.NET application is hosted on a web server, which is where C# executables reside, but it renders HTML to clients via browsers such as Internet Explorer (IE).

C# Web Application

In all of this processing, your assemblies, which were built with C#, stay on the server. When ASP.NET receives the request, it sends it to your code for processing. The great majority of the time, you don't ever have to emit HTML manually because the object-oriented ASP.NET APIs take care of it for you.

The most important point to remember is that your C# code runs on the server, not on the browser.

Scalability is a property of software that defines how well it can handle an increased workload. Applications that reach a threshold and then crash or slow to a crawl aren't very scalable. You want a scalable application that performs well at the projected peak capacity for your requirements.

To add the component

1. In Solution Explorer, right-click the project name.
2. On the shortcut menu, click Add, and then click Add Component.
3. The Add New Item dialog box appears and the Component Class in the right pane will be selected by default.
4. Accept the default name (Component1) and click Open.
5. Unless you choose another name for the component, this creates a new file in your project named Component1.cs or Component1.vb depending on the application language.
6. The Component Designer opens a design view on Component1.cs or Component1.vb.

Creating the Web Application Project Using Visual C#

To create the Web Form:

1. On the File menu, click New, and then click Project. The New Project dialog box appears.
2. In the Project Type pane, click Visual Basic Projects or Visual C# Projects, and in the Templates pane, select ASP.NET Web Application.
3. Name your application MyWebForm by changing the default name in the Location box (such as http://localhost/WebApplication1 to http://localhost/MyWebForm).
4. Click OK.

The application wizard will create the necessary project files, including the following files:

FilePurpose
WebForm1.aspxContains the visual representation of the Web Form.
WebForm1.aspx.cs or WebForm1.aspx.vbThe code-behind file that contains the code for event handling and other programmatic tasks. To see this file in Solution Explorer, click the Show All Files icon, and then expand the WebForm1.aspx node.

Note: If Solution Explorer is not open, on the View menu, click Solution Explorer.

State Management

In C# web application development the global state management of the application is taken care of by different methods.

Global State with Application is used to hold information common to all of the application instances. This is where Application state can be used.

Holding Updatable Information in Cache is to hold information in memory to avoid the overhead of creating or retrieving that information yourself.

Holding State for a Single Request features hold on to that state for an extended period of time. Holding too much information in memory affects the scalability of your application.

Issuing Cookies is information with a max size of 4K that you can ask users to hold in their browsers. Whenever the browser visits your site, it presents all cookies that your site gave to it.

User-Specific Information with Session State holds information for a specific user. When the user visits the page, ASP.NET issues a cookie with a session ID. It then manages Session state for that user, based on the user's session ID.

Understanding Page State in ViewState.

Page Reuse with Master Pages and Custom Controls: it is more work than necessary to duplicate this information on each page, especially with ASP.NET, which instead enables you to implement user controls and master pages.

Navigation

In C# web application development you can use a HyperLink control, but that is a pretty limited version of navigation. To add menus and other sophisticated controls, like breadcrumbs, to make a site more usable, ASP.NET enables you to do this with Menu, TreeView, and SiteMapPath controls.

1. Defining Site Layout with Web.sitemap.
2. Navigation with the Menu Control.
3. Theming a Site.
4. Securing a Website.
5. Data Binding.

Theming a Site

With themes, you can design a set of skins and CSS styles that apply to the entire site. To add a theme, right-click the web project, select Add ASP.NET Folder, Theme, and name it Custom. You can add multiple themes; they must have different names.

Creating Skins.

1. Add a Label control to a page.
2. Right-click the Custom theme folder, select Add New Item, Skin File, name the file Custom.skin, and click the Add button.
3. Open Custom.skin, copy the Label control from step 1, and paste the Label control into the Custom.skin file.

<asp:Label ID="Label1" runat="server" Text="Label"
   BorderColor="Green"
   BorderWidth="2" Font-Italic="True"></asp:Label>

Securing a Website

In a C# web application select WebSite, ASP.NET Configuration.

1. Create a website by selecting File, New, Project, ASP.NET Web Application, and choose ASP.NET Configuration in the Project menu.
2. Click either the Security link or the Security tab.
3. Click Use the Security Setup Wizard. The wizard, which walks you through seven steps, will open.
4. The first screen is a welcome message. Click Next.
5. ASP.NET enables you to use Windows or ASP.NET security.
6. To set up a custom database, run aspnet_regsql.exe.
7. Check the Enable Roles for This Web Site check box.

Data Binding

Data binding works on a number of controls, including ListView, FormView, ListBox, DropDownList, and others. These controls have a DataSource property that takes an IEnumerable collection to bind to.

1. Drag and drop a ListView control onto the design surface of a web form.
2. From the ListView Action list, select New Data Source in the Choose Data Source area.
3. After a couple of seconds, the Data Source Configuration Wizard will appear. You'll see several data sources, most binding directly to the data source.
4. Select Object, which is the ObjectDataSource control, and click the Next button.
5. Select HospitalManager and click the Next button. If you recall, HospitalManager is the business object we created in the preceding section.

Error Handling

For C# exception handling, consider the error-handling methods used in programming languages with no built-in exception-handling mechanism.

Error Handler Syntax:

try
{
   // some algorithm
}
catch (Exception e)
{
   // exception handling code
}

1. The Basic try/catch Block.
2. Finally Blocks.
3. Handling Exceptions.
4. Checked and unchecked Statements.

Computer Science Exam Resources: .NET Technology

Comprehensive Study Resources for .NET Technology

Access comprehensive study material for .NET Technology, including revision notes, concept maps, and high-probability questions. These resources are designed in alignment with the latest 2026 CBSE syllabus for Computer Science to support effective exam preparation.

Understanding Marking Schemes

Each resource draws directly from authorized textbooks to maintain academic accuracy. Evaluating solved examples allows students to master the formal presentation and answer-writing standards expected in upcoming school exams.

Complete Revision for Computer Science

Maximize your grade potential by utilizing Computer Science practice papers in tandem with these structured notes. All printable assignments and interactive mock tests on our platform are updated for the 2026 session and available free of charge.

FAQs

Where can I find the most advanced study material for [current-page:node:field_board] [current-page:node:field_class] Computer Science for 2026-27?

The latest 2026-27 advanced study resources for Computer Science are available for free on StudiesToday.com which includes NCERT Exemplars, high-order thinking skills (HOTS) questions, and deep-dive concept summaries.

What does the 2026-27 Computer Science study package for [current-page:node:field_class] include?

Our exhaustive Computer Science package includes chapter wise revision notes, solved practice sheets, important formulas and Concept Maps to help in better understanding of all topics.

Is this study material enough for both [current-page:node:field_board] exams and competitive tests?

Yes. For , our resources have been developed to help you get better marks in school exams and also build fundamental strength needed for entrance tests including Competency Based learning.

How should [current-page:node:field_class] students use this Computer Science material for maximum marks?

in , students should use Active Recall method, read the concept summary, then solve the Important Questions section without looking at the answers and then check your answers.

Can I download [current-page:node:field_class] Computer Science study notes in PDF for offline use?

All Computer Science study materials are provided in mobile-friendly PDF. You can download and save them on your device.

Are the [current-page:node:field_class] Computer Science resources updated for the latest NEP guidelines?

Yes, our team has ensured that all Computer Science materials for are strictly aligned with the National Education Policy (NEP) 2020 and the latest 2026-27 syllabus.