C# and .NET interview questions with answers – What is Nuget?

Many times you would like to use open sources like Nunit, Log4net, Jquery , Ninject etc  in  your project. To do the same you need to search them, download the DLL’s, check which is a proper version, add it to your project etc.  Sometimes integrating these DLL’s are very complex it needs to be configured, some of the config files needs to be updated etc.

All the above things are now simplified using Nuget. Nuget is a nothing but it’s a visual studio extension, once this extension is installed, you just need to fire the “install” command to get the DLL’s in your project.

For instance if you want to include nunit in your project, you just need to type:-

Install-Package NUnit

Nuget

 

 

 

You can visit our site for more such .Net and c# interview questions on http://www.dotnetinterviewquestions.in/

Posted in .NET and C# training, .Net Interview Questions, .NET interview questions with answers, C# interview questions, Csharp interview questions, progarmming interview questions, What is Nuget | Tagged , , , , , , | Leave a comment

23 important SQL Server interview questions on Database concepts

23 important SQL Server interview questions on Database concepts

This section will cover the most asked SQL Server interview
questions
by the interviewer so have a look on the following and do revise it when ever you go for the SQL Server interview

Normally SQL Server interview starts with…..

What is database or database management systems (DBMS)?

What is difference between DBMS and RDBMS?

What are CODD rules?

Is access database a RDBMS?

What is the main difference between ACCESS and SQL SERVER?

What is the difference between MSDE and SQL SERVER 2000?

What is SQL SERVER Express 2005 Edition?

What is SQL Server 2000 Workload Governor?

What is the difference between SQL SERVER 2000 and 2005?

What are E-R diagrams?

How many types of relationship exist in database designing?

What is normalization?

What are different type of normalization?

What is denormalization?

Can you explain Fourth Normal Form?

Can you explain Fifth Normal Form?

What is the difference between Fourth and Fifth normal form?

Have you heard about sixth normal form?

What is Extent and Page?

What are the different sections in Page?

What are page splits?

In which files does actually SQL Server store data?

Can we have a different collation for database and table?

So friends answering to above question on Database concepts of
SQL Server interview questions helped me to clear in front of the interviewer.

Posted in .NET and C# interview questions and answers, .NET and C# training, .Net Interview Questions, C# interview questions, Csharp interview questions, Interview question, programming interview questions, SQL Server, SQL server training | Tagged , , , , , | Leave a comment

ASP.NET interview questions: What is impersonation in ASP.NET?

By default, ASP.NET executes in the security context of a restricted user
account on the local

machine. Sometimes you need to access network resources such as a file on a
shared drive, which

requires additional permissions. One way to overcome this restriction is to use
impersonation.

With impersonation, ASP.NET can execute the request using the identity of the
client who is

making the request, or ASP.NET can impersonate a specific account you can
specify the account

in web.config.

Also do have a look on below video what is Authentication and Authorization in
asp.net.


Please click here to see more Asp.Net
interview questions

Posted in .net, .NET and C# interview questions and answers, .NET and C# training, Csharp interview questions, impersonation, programming interview questions | Tagged , , , , , , | Leave a comment

Algorithm interview questions and answers: – How does selection sort algorithm works?

Selection sort is the most simples sorting algorithm.  It finds the lowest value from the collection and moves it to the left. This is repeated until the complete collection is sorted.

Below is a pictorial representation of how selection sort works. We have simple collection down below which has 5, 7, 1, and 0 values.

Step 1:- Find the smallest value from the collection. In the current collection the smallest value is “0”. Move this smallest value to the left hand side.

Step 2 :- Iterate again to find the next smallest value. The next smallest value is “1”. Move this value to the left hand side before the first smallest value.

In this manner continue with all elements in a collection and your list is sorted.

sr

Below is a simple c# code for selection algorithm.

// array of integers to hold values

  private static int[] a = new int[4]{2,8,0,3};

static void Main(string[] args)

{

Sort();

foreach (int temp in a)

{

Console.WriteLine(temp);

}

Console.ReadLine();

}

public static void Sort()

{

int i, j;

int min, temp;

for (i = 0; i < a.Count() – 1; i++) // Loop through each element

{

min = i; // Assume that he is the smallest

for (j = i + 1; j < a.Count(); j++) // Loop through the remaining element

{

if (a[j] < a[min]) // If the current value smaller than the min

{

min = j; // Swap the values

}

}

temp = a[i]; // Store the current value in temp variuable

a[i] = a[min]; // Swap the minimum  value to the current position

a[min] = temp; // Swap the current value to the minimum value position

}

}

Also read inserted algorithm interview questions and answers  from http://dotnetinterviewquestion.wordpress.com/category/inserted-algorithm-interview-question/

Also read Bubble sort algorithm interview questions and answers from http://dotnetinterviewquestion.wordpress.com/2013/03/30/net-interview-questions-and-answers-can-you-write-code-for-bubble-sort/

You can also see c# interview questions and answers from www.questpond.com

This question is taken from the book c# interview question book written by Shivprasad koirala. You can buy the book from these shops à http://dotnetinterviewquestion.wordpress.com/buy-interview-question-books-from-our-shops/

Posted in Algorithm interview questions, c# data structure interview questions, Csharp interview questions, Data structure interview question, How does selection sort algorithm works, Java algorithm interview question, Java data structure interview questions, programming interview questions | Tagged , , , , , , , , | Leave a comment

Algorithm interview questions and answers: – What is inserted sort algorithm?

In inserted sorted algorithm we compare the current element value with the previous element value. If the current value is smaller than the previous value we swap. This continues until the complete list is sorted.

Let us try to understand the same by using the below diagram. In the below figure you can see we have an unsorted list with values 6,1,3,2.

Step 1 :- So we start with the first element i.e. “6”.There is no element before 6 , so we leave it and we start from 1. We compare “6” and “1”. “1” is smaller than “6”, so we swap.

Step 2:- Now we move to the next element “3”. Is “3” smaller than “6”, yes. So we again swap.

Step 3:- Now we compare “6” with the next element “2”. “2” is smaller so we swap again. There are no more further elements which can be compared with “6”. So the “6” value iteration stops here.

Step 4:- Now we take the next element “1”. There is no element before “1” so we move ahead. We move to the next element “3”. Is “3” smaller than “1” , no , so things are left where they are. So the iteration for “1” is done.We then move to the next element “3”. We compare “3” with “2”. “2” is smaller than “3” so we swap. Now “3” is compared with the next element “6”. “3” is smaller than “6” so the elements are left where they are.

Step 5 :- Now we take the last element “2”. “2” element is larger is than “1”, so “2” and “1” stay where they are. The complete collection is now sorted.

algorithm

Below is a simple c# inserted algorithm code.

class Program

{

// array of integers which holds unsorted value.

private static int[] UnSortedArray = new int[4]{6,1,3,2};

// Insertion Sort Algorithm

static void Main(string[] args)

{

sortArray();

foreach (int i in UnSortedArray)

{

Console.WriteLine(i);

}

Console.ReadLine();

}

public static void sortArray()

{

int MainLoop; // This variable will helps us loop through all the elements

int InnerLoop; // This variable will help us loop through all elements for every value

int CurrentValue;

for (MainLoop = 1; MainLoop < UnSortedArray.Count(); MainLoop++) // loop  through all the elements in the array.

{

CurrentValue = UnSortedArray[MainLoop]; // Take the current value

InnerLoop = MainLoop;

// Loop through all elements for that value

while ((InnerLoop > 0) && (UnSortedArray[InnerLoop - 1] > CurrentValue))

{

//if the previous value is greater than currentvalue swap

UnSortedArray[InnerLoop] = UnSortedArray[InnerLoop - 1];

InnerLoop = InnerLoop – 1;

}

// If previous value is not greater then just keep the value where they are.

UnSortedArray[InnerLoop] = CurrentValue;

}

} 

You can also see Algorithm interview questions from www.questpond.com

This question is taken from the book .NET interview question book written by Shivprasad koirala. You can buy the book from these shops à http://dotnetinterviewquestion.wordpress.com/buy-interview-question-books-from-our-shops/

Posted in Algorithm interview questions, c# algorithm interview questions, c# data structure interview questions, Csharp interview questions, Data structure interview question, Inserted algorithm interview question, Java algorithm interview question, Java data structure interview questions, programming interview questions | Tagged , , , , , , , , | Leave a comment

.NET interview questions and answers: -How can you define a property read only for external world and writable in the same assembly?

Let’s us first try to understand this c# / .NET interview question and answers. Let’s say if you have a class called as “Customer” with a property “CustomerCode”.Now you want that anyone can read from the “CustomerCode” property but this property can only be set from within the assembly.

In other words any one canrun the below code.

Customer obj = newCustomer();
string x = obj.CustomerCode;

But setting of the value can be only done from within assembly. The below code will run only if it’s within assembly and it will throw error if it’s external to the assembly.

Customer obj = newCustomer();
obj.CustomerCode = “c001″;

This can be achieved by have different access modifiers for “SET” and “GET properties on the “CustomerCode” property. In case you are new to access modifiers , see c# interview questions :- What are the different access modifiers in c# ?.

So for the “GET” we will have public access modifiers and for “SET” we will apply internal access modifiers.  Now because “GET” is public this property can be read anywhere and because the “SET” is internal it can only be accessed from within assembly. Below goes the code for the same.

classCustomer
     {
privatestring _CustomerCode = “”;

publicstring CustomerCode

{
get { return _CustomerCode; }
internalset { _CustomerCode = value; }

} 

}

This question is taken from the book written by Shivprasad koirala .NET interview questions by BPB publications.

You can see SQL Server interview questions and answersarticle which is hosted on code project.

Posted in .NET and C# training, .NET interview questions and answers, Csharp interview questions, define a property read only for external world, programming interview questions, writable in the same assembly | Tagged , , , , , | Leave a comment

Algorithm interview questions and answers: – Can you write code for bubble sort algorithm?

In some of the bigger companies like google , Microsoft etc  algorithm has been a favorite topic during c# interviews. So we are starting with a dedicatedseries which mainly targets how to write these algorithms in c#. So let’s start with the famous one bubble sort.

Bubble sort is a sorting algorithm which steps through a collection repeatedly, comparing and swapping until the collection gets sorted.  Below is a simple pictorial representation of how bubble sort works.  We have a simple number collection of values 5, 1, 3 and 4 and we would like to sort them in an ascending manner.

Step 1 :- So we first start with number 5. The adjacent number to 5 is 1. So we compare 5 with 1. Now 5 is greater than 1 so we swap position of 1 with 5 and 5 with 1. Look at Step 2 for the final image after swapping.

Step 2:- Now we compare 5 with 3. 5 is greater than 3 so we swap position of 5 with 3 and 3 with 5. This continues until 5 has been compared with all numbers in the list. Step 4 is the final position for number 5.

Now we take the second number i.e. 1 and we compare and swap 1 with all other numbers until it reaches its final position. This is done with all numbers in the collection.

Sorted change

Now to implement the above logic in c#it’s a two-step process.

  • Loop through all elements in the collection.

Below is a sample code which loops through all elements in a list called as unsorted.

// Loop through all elements
for (int i = 1; i <= unsorted.Count; i++)

{

}

  •  For every element in the collection compare and swap with all the remaining elements.

Now for every element we need to loop through the rest of elements. In other words we need a nested for loop.  The outer “for loop” loops through all elements and the inner “for loop” loops this element with other elements. Please note the loop runs till unsorted.Count-i.

// Loop through all elements
for (int i = 1; i <= unsorted.Count; i++)

// All elements compare / swap with rest of elements
for (int j = 0; j < unsorted.Count – i; j++)

{

// Compare and Swap logic goes here

}


Below is the compare and swap logic which goes in the inner loop.

if (unsorted[j] > unsorted[j + 1])

{

temp = unsorted[j];

unsorted[j] = unsorted[j + 1];

unsorted[j + 1] = temp;

}         

Below is the full final code for bubble sort.

static public List<int> bubblesort(List<int> unsorted)

{

int temp;

for (int i = 1; i <= unsorted.Count; i++)

for (int j = 0; j < unsorted.Count – i; j++)

if (unsorted[j] > unsorted[j + 1])

{

temp = unsorted[j];

unsorted[j] = unsorted[j + 1];

unsorted[j + 1] = temp;

}

return unsorted;

}

Visit us at www.questpond.com for more .NET interview questions and answers

This is a nice c# interview question :- What are partial classes in c# ?

Posted in Algorithm interview question, Bubble sort algorithm interview questions, c# algorithm interview questions, c# data structure interview questions, Csharp interview questions, Data structure interview question, Java algorithm interview question, Java data structure interview questions, programming interview questions | Tagged , , , , , , , , , | 1 Comment