Category Archives: C# Articles

Answer – C# Event Handling Exercises

Qu: Write a program for Online Attendance. The conditions are as follow:

  1. User provides their name as Input and then application show message to “Welcome to their Name”.
  2. Jack, Steven and Mathew are banned for the organization. So, when any user enters Jack, Steven and Mathew as user name, the application raised an event and fire alarm as well as sends email to administration.



When this program gets executed and user enters any of the banned user name, the program started beeping for infinite time. You must press ctrl + c to stop this beep sound.

C# – How to Use Const in Inheritance

In this tutorial, you will learn to use const in Inheritance.

Programming Example

This example contains a class Laptop which inherits be base class LaptopBase. LaptopBase has several const values that are used in main method.

This program is showing different types of laptop with details. All the details are constant and cannot be changed.


Name : Lenovo
Price : $1000
Processor : i3
Ram : 2GB
HDD : 500GB


Name : Dell
Price : $1500
Processor : i5
Ram : 4GB


Name : Sony
Price : $2000
Processor : i9
Ram : 8GB


C# Randomize Char Array with Programming Example

In C#, there is way to randomize char array. Following program explains it clearly.


3 , 2 , 1 , A , C , B ,

Why ASP MVC is much better than ASP.Net WebForms? vs mvc
If you are or you want be Asp Web developer, you must know about ASP.Net MVC and reasons why it is much better than ASP.NET Web Forms.

ASP.NET is a biggest success of Microsoft and it successfully delivered Web Application for past 12 years. It is easier for web developer to develop web forms using than other architecture. A developer can drag and drop control onto web forms and visual studio automatically generates event based code behind control. So, the programmer can easily write code on the click_event of control. It seems so pleasant to developing project over but there are some serious problem with so, Microsoft decided to overcome these problems by launching ASP.Net MVC.


So, whats the problem with ASP.Net?

There are some serious problem with ASP.Net architecture that is listed below.

  1. Performance Issue: net has slower server response, huge and complex page cycle life and consumes heavy bandwidth.
  2. Server Control: If you are an developer you might know about server control. Now, the simple question is why need to server control if you have light weight html control in hand. Microsoft cleverly shows you that you are working on event driven programming architecture but in reality a server control converts itself into a simple control. For example:


If you drag a text box in web forms you see the following code in .aspx file

But what actually happened behind it? If you see the original output of the above code you get this code.

So, the question is why need to do more server trip for a simple control if you have handy html control to work. And just imagine what happened if you have dozens of control on the page. The page becomes slow and unresponsive several time. It is a biggest headache for end user.  So, the solution is get rid of Server Control.

Introducing MVC

Now, let’s discuss about MVC Architecture.  MVC stands for Model, View and Controller.

Model: It is middle layer between View and Controller.

View: It is pure HTML Design

Controller: It contains all the coding logics.

So, How MVC works?

Steps 1: User first clicks a button and the request goes to controller. Don’t forget that controller is an area where your programming logic resides.

Steps 2: Based on request Controller creates the object of the Model. Model invokes data access layer which fetches data in the Model.

Steps 3: Now the model which is loaded with data; passed to view for display purpose.

Features of ASP.Net MVC

  1. It is lightweight and follows Model, View and Controller based architecture.
  2. It has not server control instead a designer can design a page in pure HTML and CSS.
  3. Microsoft removes View State in MVC.
  4. In MVC, Views and Logic are kept separately.
  5. It has no Master Page instead MVC has Layouts for consistent look and feels.
  6. Net MVC is an Open Source.


In my suggestion if you are an ASP.Net Developer you must upgrade yourself with MVC. For Beginner -skip learning ASP.Net Web Forms (because it is outdated) and start learning MVC.

C# String Functions and Properties

In this chapter you will learn

  • What is string?
  • How many types of string function in C#?
  • How to use C# string function in programming?
  • What is the difference between string and String?

In C# programming, string is another kind of data type that represents Unicode Characters. It is the alias of System.String however, you can also write System.String instead of string. It is the sequence of character in which each character is a Unicode character. Continue reading C# String Functions and Properties