C# Articles




List of Articles in C-Sharp


01) Introduction to classes and objects

A class is a blue print or a template. One or Many outcome of the template is known as object(s).  Read More


02) Passing parameters to a function by Value and by Reference

In this article we will look at the parameter passing difference when it is passed as value or passed as reference.  Read More


03) Overloading the casting operators


We know that standard data types supplied by languages are well known and there will be operators like +,* ,% operates on these data types.  But, what is the case if it is user-defined types say a 3dpoint class, which is the combination of three integers. Well, all languages that supports operator overloading says, “It is you Type. Please you say how the operator + should work”.  Read More


04) Interfaces in C#


An interface is a contract. If you are defining an interface, then you are describing set of rules. A class can follow the rules specified by the interface. When a class fulfills the contract or rules specified by the interface, we could say that a class implements the interface. Read More


05) Position based indexers vs. Value based Indexer


In this article we will look how we can implement our own indexer for our collection class. We will have a look at both position and value based indexers. Read More


06) Support Foreach for your Collection class



“ForEach” is loop like “For”, “While” etc. When you are using foreach loop you no need to worry about where the collection starts and where it ends. These are taken care by the foreach loop itself. You may already use it when you are working with array. If not, below is a simple example:
int[] numbers = new int[4];
numbers[0] = 1;
numbers[1] = 2;
numbers[2] = 3;
numbers[3] = 4;
foreach(int num in numbers)
            Console.WriteLine(num);
The foreach loop above will iterate through all the 4 numbers allocated on the array and prints that in the console window. Note that we do not worry about start and end as it is taken care by the foreach. Now, let us move how can we implement such a foreach for our collection classRead More


07) Stack and Queue


Stack and Queue both are collection classes sported by the dot net framework. Queue operates on First in First Out (FIFO) principle. Stack operates on Last in First out (LIFO) principle. That is; Read More


08) Exception Handling Part - 1


An Exception is an object delivered by the Exception class. This Exception class is exposed by the System.Exception name space. Exceptions are used to avoid system failure in an unexpected manner. Exception handles the failure situation that may arise. All the exceptions in the dot net framework are derived from the System.Exception class. Read More


09) Exception Handling Part - 2


This class is provided by dot net framework to handle any exception that occurred. The Exception class is the base class for all other Exception class provided by dot net framework.
The exception object has some important properties. Some of then are given below:
Property
Usage
Message
Gives detailed information about the message.
StackTrace
Gives the function stack to show where exception is thrown
Target site
Shows which method throws the exception
In the previous part we only used the catch block and missed all the above said information. The exception object is thrown by the piece of code, which raises an Exception and the handler code catch that Exception object and make use of the information packed in it.. Read More


10) Delegates Part - 1


Delegate is a reference type just like other object. When you create an object, the memory is allocated for the object on the heap and reference for it is stored in the reference variable, which is in the stack. Consider the below statement: 
Organization Org = new Organization("C# Corner", staff1, staff2, staff3, staff4 );
Here, the organization object is created on the Heap memory and a reference to that memory location is stored on the stack identified by the token Org. Like the Org reference, the delegate reference type will refer to the function address. At runtime the function will be loaded into a code segment of memory like Heap Segment for object created using new keyword. If we take the starting address of the function (First line of translated code) in the Code segment and store it in a reference variable we call that reference variable a Delegate. Read More


11) Delegates Part - 2


In the previous part we saw how we can use a simple delegate. In the article I will explain what is a multicast delegate and how we create and use it. Multicast delegates are the combination two or more delegates of same type and they together form a delegate chain. Each participant in the delegate chain should have a void return type. Read More


12) Creating Custom Events


An event is kind of ‘Something Happened’. Some examples are the button got pressed; a check mark from the check box is removed. We all know that we call this kind of action as Events happening to those controls. Read More


13) Form Fade-out



In this article I will explain how to display the form that goes fully transparent before the form get closed. Follow the below specified steps and I will give some explanation when the step requires it. Read More




14) Modal and Modeless forms



In this article I will walk you through how do you create different forms and access form from other forms. While we developing I will help you to understand model and modeless forms and some important control properties. Read More





15) Auto Complete Textbox



The auto complete feature of the text box allows the user to enter part of the details in the text box and complete the remaining automatically. Say for example a country text box, which will fill the entry India when first two letters are typed. There are two important way we can save the typing. One is auto complete by filling the remaining text and other one is providing a suggestion in the form a matching list to pick the correct one. Read More





16) Listboxes and how do we use it



In this article we will look at how do we use listboxes. First we will start with simple list box then we go ahead and deal with checked list boxes. Finally we will lear how to prohibit selecting some particular listbox items. Read More





17) Linklabel and Numericupdown control



Linklabel is kind of label control but it serves the concept of hyperlink. With this control you can mark portion the label text or even the entire label text with an underline. Clicking on the underlined text raises the event LinkClicked. By providing the handler for this event you can take an action.
NumericUpDown control is combination of text box and a pair of arrows pointing is opposite direction. Clicking the arrow or holding the mouse pointer on the arrow will increment or decrement the associated value. The current value is displayed on the text box part of the control. When we click the arrow an event ValueChanged is raised for taking the action. Read More





18) Picturebox and Progressbar controls



In this article we will explore the PictureBox and Progressbar controls with an example walk through. Picturebox control is mainly used to an image. The image type can be bmp, jpg, gif, png etc. Progressbar control is used to show the progress of long running process visually.
I will walkthrough an example and explain the control properties and methods and events when it is used in the application. Read More





19) Stream Reader, Stream writer and with OpenFile and SaveFile dialogs



Here you will see how to use File open dialog and folder select dialogs. Also you will see how do we use StreamReader and StreamWriter class. We also are going to use Path utility class, which has static function to phrase the string that comes in the form of file pathRead More




20) Important Project properties that one should know


Here, I will explain some important project properties with examples. I will show you the following in this article:
1) How do you set Output path for your binaries?
2) How do you set version and other file information to your output binary?
3) How do you set Icon to your project?
4) How do you conditionally compile some piece of code?
5) How do you ask compiler to skip some warning or treat a warning as error?
6) How do you use Pre-Build and Post-build events?
7) How do you debug a dll and get a hit to the break point when the when the dll project in not part of the solution in which exe resides?Read More


21) Introduction to debugging


Debugging is the process of finding the logical errors on the program by examining the statements during the execution. The execution of a program pauses when the breakpoint is hit. Here, I will walk you through the debugging the sample application supplied with this articleRead More

22) Some useful debugging windows


In this second part we will still use the same sample that we used in the previous part. Here, we will cover some other important windows that help the process of debugging. Read More


23) Tracing the Debug info using TraceListeners


In this third and last part of the debugging I will show you how do you get debugging information in the form trace. This will be helpful when the application deployed in the customer place. It is not possible to do the debugging, as we usually do not keep the source code on the deployed environment.
Dot net framework provided a facility to do the tracing on the client end and you can the information from them in the form of flat text file or as an event log file. In this article, we will change the existing sample used in the previous two parts to enable the logging in the flat text file as well as in the windows event logger. Read More




24) Container Control : GroupBox


In this article we will explore the usage of the container controls. The container controls are treated by the top most container say a dialog as a control. The container controls can hold some other controls. First we will explore the Group box container control then we will move ahead with other container controls. Read More




25) Container Control : Panel


The container control panel is all about this article. We will see how do you use the panel control to group the controls and then we will explore the important properties of this container along with this example. Read More








26) Container Control : Split Container


A Split Container is a combination three components.  Panel1 and Panel2 separated either horizontally and vertically by a splitter.  A split container is useful to create your favorite windows explorer like user interface. To set the properties for the panels you should click the panel portion of the container. To select the entire container, click on the splitter. You can set different set of properties for the panels on both side of the splitter. Read More




27) Container Control : Tab Container Control


TabControl is collection of Tab pages. Each tab page can act as a separate container. And we all know that a container can hold controls in it. The simple explanation for Tab Container is, a container, which can hold N number of containers in the form of book pages. The tab control is useful to group the controls based on the information they give or receive. Say for example, in the credit card transaction screen, the personal information can be kept in one tab page, and the actual card details and the amount of transaction can be kept in other page. In most cases, people usually go for the tab control when the form is not enough to fit all the controls.
Here we will see how do we use the tab container, then we will add some tab pages dynamically. Finally we will explore some important property for this control. Read More





28) Container Control: FlowLayoutPanel


Flow Layout Panel container arranges the controls in a specific pre-defines orders. When the Container holding the control is resized the controls are automatically arranged inside the container to maintain the flow specified.
In this example we will place some controls inside the flow layout container and see some important properties and methods that controls the container content. Read More




29) Container Control: TableLayoutPanel


Do you know how the Table works in html? The TableLayoutPanel works almost the same way that the table works in html. In this article we will see how the TableLayoutPanel can be used. How each cells of this panel behaves. Also we will combine some other layout panel. At the end you will see a small profession looking form that can be used by a hospital management applications.
OK. The TableLayoutPanel is collection something called cells and these cells can be arranged in rows and columns. You can imagine each cell as a special container. Why I told it as special container? Well. Each cell can hold only one control in it. What if I need to have multiple controls in one cell? Actually that is not required most of the time. But if you still need an answer, place a container you like in that cell and start placing the controls inside container that occupying the cell. Read More




30) MenuStrip Control


Strip is a relatively narrow piece of something. Dot net has three important strip controls namely MenuStrip, StatusStrip and ToolStrip. In this article we will start with the menustrip control. Read More




31) ToolStrip Control


Just Like menustrip control toolstrip control also a relatively large piece of placeholder where you can place icon buttons, combo box, labels etc. In this article we will look at the usage of the toolstrip controls Read More




32) StatusStrip Control


Status strip is a family of strip controls like MenuStrip and ToolbarStrips, which is usually used to display some quick help and information to the user who is using the application. A status strip control will look like the one shown below:
C# status strip control allows you add even combo and textboxes to the status. In this example we will have a look at how we add status bar to the application and how will we use it. Then we will look at some of the important properties and using that efficiently. Read More





33) Implementing NotifyIcon control to use systemtray




We know that a long running background processing application will make use of system tray as they do not want to interact with you. But in the meantime as a user you may need to know what is the status of the background application or what it is doing or get some input from it etc., 


This article implements a Notify Icon with a simple sample. Read More




34) Using the MaskedTextBox control



Masked Edit control is special form of edit control. In edit control user enter the data and we do validation and manipulate that data to a specific format if required before persisting that information into the database. But, the masked edit control takes the data in the formatted way and at the mean time in validates the keyed-in data. Say for example we you expect a number; you can reject all other key INS.

The mask property controls the data format and data character validation. Like the text box control, the output from the masked edit also read from the text property. Read More




35) Using RichTextBox Control in C#



Just like textbox rich text box also similar kind of control, which accepts text input. What is difference between typing a three page document in notepad application and as well as Microsoft word application? Are you piling up the differences? OK. The difference that came in your mind is the difference between the TextBox versus RichtextBox. This means unlike the normal textbox, in the richtextbox you can mark piece of the text and set different characteristics like bold/italic, different text color etc. Read More



36) Playing Wave Sounds


We will see how we can play sound files in C#. Sound can be played in two different ways. One way of playing is using the System.Media namespace and the other way is using the Windows Media Player Active-X Control... Read More




37) Using BackgroundWorker Component



BackgroundWorker component is used to perform long running tasks in the background while the application running in the foreground will still look for the user events and responds to them. Usually when application is busy (i.e.) performing a long running task, users of the application cannot interact with the UI elements and the only existing thread is engaged with that long running task. Here... Read More



38) Monitoring a FileSystem Using FileSystemWatcher


FileSystemWatcher component will track the changes in the file system. The changes include file creation, deletion, Modification and renaming a file. In this article we will create sample that can spy on your file system based on the folder path that you specify. Read More





39) Making Use of WebBrowser Control


The dotnet WebBrowser control provides the capability of browsing the web pages to your application. You can also display your own html content through the web browser control. That means you can generate all fancy report and display that in a web browser control. In this article, I will show how. Read More





40) Publishing C# Applications


This article explains publishing the application in the network share path. It also explains how do you push the application updates to the installed locations. The article will walk you through Publishing the Application, installing published application, updating the new version in the published location, notifying the clients with the new update... Read More







41) Generating RDLC report using dotnet framework


In this article I will walk you through generating a report using the Microsoft supplied report template (.rdlc file). We will get the data from the “Titles” table of the Microsoft supplied “Pubs” database.. Read More




42) Retrieve List of stopped services using WMI Query

 
What is WMI? WMI stands for Windows Management Instrumentation. WMI is set of classes living in a separate world of dot net framework in the form of wrapper classes around set of native classes that retrieves hardware information. Say for Example, if I want to retrieve the information like remaining battery in my laptop when it is off the power Read More


43) GDI+ Drawing using Pen and Brush


This article explain how do you perform drawing in GDI+ by drawing on screen with differen Pen and brush configurations. Once you learn this, you start using the Pen and brushes easily in your drawing.  Read More








44) Creating OwnerDrawn ComboBox



When we place a control on the form, the control’s appearance is usually decided by the control itself. Let us say for example that you placed a List Box control on the form, the appearance of ListBox control is drawn by the dot net frame code written for that control itself. That means, the ListBox class Read More





45) Reading Data From App.Config File



Let us say you are developing an Internet modem device monitor utility application. The duty of the application will be monitoring for Upload and download activity of the modem. When there is heavy download say 500KB per second of download for past 10 Minutes, the device should intimate that to a user. The intimation can be done either by blinking a Red LED modem device or by making continues beep or by making the entire desktop with red transparent overlay (System got RED by download J). But, which option the utility should chose from? Now I hear you are saying keep it as an application setting. Read More




46) Dynamically updating the App.Config file


This article explains how do we update the application configuration file at run time and retrieve the updated content without restarting the application. Read More










47) Running a Batch file as Process


This article explains starting a simple process by displaying notepad. Later the article goes on explaining - running the batch file process, passing parameters to it, running it silently. The article end by showing receiving a exit notification from the spawned process. Read More



48) Creating Custom Performance counters


This article explains how can we create our own performance counters using C#.Net with a suitable example displayed on the right side. Here, the button clicks are tracked with two custom performance counters. Read More




49) Using Debugger Break, Log and getting Stack Trace in C-Sharp


This Tutorial Article shows how do you use the debugger object to log information into Output window. It also shows getting Call StackTrace information and displaying it in the output window Read More




50) Debugger Attributes


This Article explains some most useful debugger attributes with examples. Through these attributes you can decide how the debugger should display the class informations in debug windows. Read More






51) Custom Debugger Visualizers


This article shows writing your own custom debugger visualizers. The article starts with what is visualizers and then walks you through creating a visualizer for the Stack collection class provided by Framework... Read More







52) CAS - SecurityAction at assembly level


This article shows writing your own custom debugger visualizers. The article starts with what is visualizers and then walks you through creating a visualizer for the Stack collection class provided by Framework... Read More




53) CAS - SecurityAction at Method level


This article with demo videos, explain the how one can make use of the below-given method level security actions:

1) Demand Action
2) Link Demand Action
3) Inheritance Demand Action
4) Deny Action
5) PermitOnly Action
6) Assert Action 

Read More

3 comments:

  1. Excellent Site. Thanks for teaching and sharing your c# knowledge.

    ReplyDelete
  2. Nice interesting information on the various concepts of C language using the objects and classes.

    ReplyDelete

Leave your comment(s) here.

Like this site? Tell it to your Firend :)