Sunday, 20 July 2014

What are enumerations? Explain it with the help of an example ?( TY BSC IT Notes for C#)

This c# question has occurred in TY BSC IT C# paper in Mumbai university for the year April 2013.

ENUM helps to define, manage and assign constants in effective way. Constants means values like 1,2,3,4 etc which do not change while the program is executing.

Now the below sample code is good but the week day values are not readable. We need to remember that “1” is Sunday , “2” is Monday and etc.

int weekday = 1; // 1 - Sunday , 2 - Monday etc
if (weekday == 1) { Console.WriteLine("Its Sunday Enjoy"); }
if (weekday == 2) { Console.WriteLine("Its monday office time"); }
if (weekday == 3) { Console.WriteLine("Its wednesday client calls"); }
if (weekday == 4) { Console.WriteLine("Its tuesday status updated"); }

Below is how you can create an ENUM. You can see how the constants are now organized in a central place.
enum WeekDays
Sunday = 1,
Monday = 2,
Tuesday = 3,
Wednesday = 3
Below is a sample code where we have used ENUM’s. You can see how the code has become more organized and readable.
int weekday = 1;

if(weekday == (int) WeekDays.Sunday){ Console.WriteLine("Its Sunday "); }
if(weekday == (int) WeekDays.Monday){ Console.WriteLine("Its monday"); }
if(weekday == (int)WeekDays.Wednesday){ Console.WriteLine("Its wednesday"); }
if (weekday == (int)WeekDays.Tuesday) { Console.WriteLine("Its tuesday "); }

Saturday, 19 July 2014

Write a C# program to do the following(TY BSC IT C# Sem 5 Notes)?

This question occurred in Mumbai UniversityThird year BSC IT Sem 5 in October 2013. You can get the Question paper from

Below goes the full question from the BSC IT question paper.

Write a C# program to do the following: Initialise an array A with 10 elements. Initialize an array B with 7 elements. Divide each element of array A with each element of array B that is a [0] / [0], a[1] / b[1] etc. Implement the same to handle Divide by zero error and index out of bound error.

Below is code with comments.
// Initialise array A with 10 elements and B with 7 elements

int[] A = new int[10]{9,8,7,6,5,4,3,2,1,0};
int[] B = new int[7]{6,5,4,3,2,1,0};

// Loop through all elements
for (int i = 0; i < A.Length; i++)
      // Divide each element of A with B
      double div = A[i] / B[i];
      Console.WriteLine(A[i] + " Divided by " + B[i] + " Gives " + div);
      // Catch Divided by zero
      catch (DivideByZeroException DivideErro)
      Console.WriteLine("Zero divide error for " + i);
      // Catch index out of range
      catch (IndexOutOfRangeException IndexErr)
      Console.WriteLine("Index out of bound for " + i);
Do not forget to visit our site on C# training site for interviews.

Sunday, 29 June 2014

List the necessary steps to publish the website in ASP.NET ? ( TY BSC IT Notes) – Mumbai university

This question occurred in April 2012 for TY BSC IT Mumbai university.

It’s a simple two-step process
  1. Create the assemblies of our website
  2. Host it inside IIS
Create the assemblies of our website
  1. After you successfully done with the asp.Net web form application development, first thing you should do is build the application.
  2. Just building won’t be sufficient. Now right click your WebSite project in Visual Studio and say publish website. “Publish Web” dialog box will show up.
  3. Select “Publish method” as File System.
  4. Next in the target location put the local address where you want to keep your assemblies.
  5. Check “Delete all existing files prior to publish” radio button.
  6. Click Publish
Host inside IIS

Once the assemblies or in short deployable part of our application is prepared next we will host it inside IIS. These are the steps for hosting it inside IIS.
  1. Click start>>Run. Type “Inetmgr”. Press OK. It will open up IIS manager.
  2. In the left section we will find a tree. In that under your “computer name” expand Sites>>Default Website.
  3. Right click Default Website and select “Add application”. Add application popup will appear.
  4. Put alias name as per your requirement. For Instance set it as “MyFirstHosting” 
  5. In the physical path put the address of you folder where published assemblies are kept.
  6. Click OK.
  7. Right click the newly created application and select “Manage Application>>Advanced Settings”.
  8. In the Advanced setting dialog box set application pool to the correct one.
    (For example make sure .net framework version of Application pool is correct)
  9. Open the browser and put the Url as http://localhost/MyFirstHosting/FirstPage.aspx.
You can also watch the video about IIS hosting in the DVD

Friday, 20 June 2014

What is method overloading? Explain with examples? ( TY BSC IT C# Solved papers)

This TY BSC IT C# question occurred in the year of 2012 in Mumbai university. You can see the full question paper at

Method overloading allows you to use a single method name but overload it with different number of parameters and types.

Below is a simple example of method overloading. We have the same method name “Add” but it’s loaded once with two parameters ( num1 and num2) and again its loaded with three parameters ( num1, num2 and num3).

public int Add(int num1, int num2)
return num1 + num2;

public int Add(int num1, int num2, int num3)
return num1 + num2 + num3;

So now if you call the “Add” method with two parameters it will add two numbers and if you call the add with three parameters it will add three numbers.

int value = Add(10, 10); // returns 20
value = Add(10, 10, 10); // returns 30

Benefit of method overloading is you do not need to create different method names like “AddTwoNumbers” , “AddThreeNumbers” etc , you just say “Add” and then number of parameters.
Method overloading also depends on data types. Below is a simple “Check” code function one takes a number and the other check takes a string. Now in this case there is only one parameter but still “Check” function is overloaded because of different data types.

public static bool Check(int num1)
            if (num1 == 0)
                return false;
                return true;


public static bool Check(string str1)
            if (str1.Length == 0)
                return false;
                return true;

So you can now call “Check” function with a string or a number type.

Check(300); // Checks if it’s a number
Check(“Test”); // Check if the string is empty.

Get Full TY BSC IT Notes and Solved question paper :- Call 022-66752917

Get full TY BSC IT Mumbai Syllabus from

Wednesday, 18 June 2014

Explain write() and WriteLine() Methods with examples ? ( TY BSC IT C# Notes)

This C# question occurred in 2012 for TY BSC IT students for the subject C# with ASP.NET .

Both “write()” and “writeline()” are methods which print’s string values to console screen of a computer.

The “Write()” method outputs one or more values to the screen without a new line character.

The “WriteLine()” always appends a new line character to the end of the string , which means any subsequent output will start on a new line.

Here is the new syllabus for TY BSC ITMumbai university last year

Monday, 16 June 2014

What is regular expression? Explain regex patterns?( BSC IT Notes for C# and ASP.NET)

This question was asked for 5 marks in Mumbai University in the stream of BSC IT in the month of April 2013 in ASP.NET with C# (Sem 5) subject.   You can see the full paper of BSC IT Mumbai university question paper from here

Full form of Regex is regular expression. It helps us to describe complex patterns in texts. Once you have described these patterns you can use them to do searching, replacing, extracting and modifying text data.

Below is a list of some important regex patterns.

Regex pattern
Check if string is numeric or not.
Check if string has only characters ( both capital and small case)
Check if string is only 3 characters
Check if string is minimum 3 characters and maximum 10
Format should be of a patter A001, E003,G009 etc. In other words should start with a single alphabet followed by 3 digit numeric values.

To use regex we need to create object of “regex” class and in the constructor we need to define the pattern. You can see in the below C# code we are specifying a pattern to find only characters. Then using the “IsMatch” function to see if pattern is matching or not.

Regex obj = new Regex(“[a-z]”); // Specify pattern
If(obj.IsMatch(str)) // Check if its matching or not
// Match found
// Match not found

Below is a C# regex training video created by  questpond team . Do see the video to understand regex in more details.

Want to take crash course in C# with ASP.NET for BSC IT call us on 022-66752917. Batches conducted now in Mulund every Saturday and Sunday.