Wednesday, May 30, 2012

Access Modifiers

PUBLIC doesn’t have any restrictions. It can be visible to any method of any class.
PRIVATE accessible for only that class.
PROTECTED marked members are accessible only to the methods of that class and its derived classes.
INTERNAL marked members are accessible to that assembly which it belongs to.
PROTECTED INTERNAL marked members are accessible to its assembly and its derived classes of any other assemblies.

Unique key and Primary key

Unique key

1) Unique key can have nulls.
2)We can create multiple unique keys on a table.
3)Unique key Creates a non-Clustered Index by default.

Primary Key   

1)Primary key cannot have nulls.
2)We can have only one Primary key on a table.
3)Primary key Creates a Clustered Index by default.

Both Unique keys and Primary keys can be referenced by foreign key.

Managed Code and Unmanaged Code

A Code that Executed with in the instructions of CLR is Called 'Managed Code'.
A Code that Execute with out the instructions of CLR is Called 'UnManaged Code'.

Difference between Webform and Webgarden in

A "Webform" is a setup of a website across multiple servers
A "Webgarden" is a setup of a website on a single server with multiple processors

Difference between String and StringBuilder in .net

Both String and StringBuilder are classes used to handle strings.
String concatenation is one of the commonly used operations among programmers.If you don't handle the string concatenation in .NET properly,it may decrease the performance of an application.
Once created a string cannot be changed.
A StringBuilder can be changed as many times as necessary. 

String : The most common operation with a string is concatenation.
When we use the "String" object to concatenate two strings,
the first string is combined to the other string by creating a new copy in the memory as a string object, and then  the old string is deleted. This process is a little long. So we say "Strings are Immutable".

Ex :
string strNumber = "";
for(int i = 0; i<1000; i++)
strNumber = strNumber + i.ToString();

StringBuilder : When we make use of the "StringBuilder" object, the Append method is used. This means,an insertion is done on the existing string.Operation on StringBuilder object is faster than String operations,as the copy is done to the same location. Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed. 

Ex :
StringBuilder sbNumber = new StringBuilder(10000);
for(int i = 0; i<1000; i++)

Nth highest Salary from the Employee table

Select * from emp e1 where in (select count (distinct e2.sal) from emp e2 where e2.sal >= e1.sal) = &n

// where n= 1,2,3,4,....
(nth highest Salary) 

What is the output of the below code?

What is the output of the below code?

<script type="text/javascript">
var x = 4 + "4";

Output : 44

Get the ClientId of Gridview in

string myGrid = "'" + this.grvEstimation.ClientID + "'";

//grvEstimation is the gridview Id

Boxing and UnBoxing in .net

C# allows us to convert a Value Type to a Reference Type,and back again to Value Types.
The operation of Converting a Value Type to a Reference Type is called Boxing and the reverse operation is called Unboxing.


 int Val = 1;
 Object Obj = Val; // Boxing (value type to reference type)


  int Val = 1;
  Object Obj = Val; // Boxing
  int i = (int)Obj; // Unboxing (reference type to value type)

Key Event in

protected void Page_Load(object sender, EventArgs e)
txtEmployee.Attributes.Add("onKeyUp", "GetKeyUpMethod(event)");

// Here GetKeyUpMethod is the JavaScript Function

Wednesday, May 16, 2012

How to Print Words in Reverse Order to the TextBox in

string strWord = "Welcome to my blog";
            string[] strArray = { "Welcome ", "to ", "my ", "blog " };
            string strOutput = string.Empty;
            for (int i = strArray.Length - 1; i <= strArray.Length; i--)
                strOutput += strArray[i];
                if (i == 0)
                    txtPName.Text = strOutput;

protected void btnSave_Click(object sender, EventArgs e)
            lblMsg.Text = PrintWordsInReverseOrder(

        static string PrintWordsInReverseOrder(string str)
            string revInputWord = string.Empty;
            string finaloutputSentance = string.Empty;
            for (int i = 0; i < str.Length; i++)
                if (str[i] != ' ')
                    revInputWord = revInputWord + str[i];
                    revInputWord = revInputWord + ' ';
                    finaloutputSentance = revInputWord + finaloutputSentance;
                    revInputWord = string.Empty;
            if (revInputWord != string.Empty)
                finaloutputSentance = revInputWord + ' ' + finaloutputSentance;
            return finaloutputSentance;

OutPut :
Input String :
 "Welcome to my blog"; 
Output String :
 "blog my to Welcome "; 

How to find the highest number in an array using .net

int[] isNum = { 1, 4, 6, 10, 9, 12, 3, 5 };
            int iMaxvalue=0;          
            for (int i = 0; i < isNum.Length; i++)
                    iMaxvalue = Convert.ToInt32(isNum[i].ToString());


int itestValue = isNum.Max();

How to write the content of Textbox to text file in

using System.IO;
StreamWriter StrmWriter_obj = new StreamWriter(Server.MapPath("Test.txt"));  StrmWriter_obj.WriteLine(txtTest.Text); StrmWriter_obj.Close();

How to read the content of text file in

using System.IO;

StreamReader Strmrdrobj =
new StreamReader(Server.MapPath("Test.txt"));
/*System.IO namespace for StreamReader */
txtTest.Text = Strmrdrobj.ReadToEnd();Strmrdrobj.Close();

Tuesday, May 15, 2012

Why we Use the ScriptManager Control in

The ScriptManager control manages client script for Microsoft ASP.NET AJAX pages. By default, the ScriptManager control registers the script for the Microsoft AJAX Library with the page. This enables client script to use the type system extensions and to support features such as partial-page rendering and Web-service calls.

we must use a ScriptManager control on a page to enable the following features of ASP.NET AJAX: Client-script functionality of the Microsoft AJAX Library, and any custom script that we want to send to the browser. Partial-page rendering, which enables regions on the page to be independently refreshed without a postback. The ASP.NET AJAX UpdatePanel, UpdateProgress, and Timer controls require a ScriptManager control to support partial-page rendering. JavaScript proxy classes for Web services, which enable we to use client script to access Web services by exposing Web services as strongly typed objects. JavaScript classes to access ASP.NET authentication and profile application services.

ScriptManager is a parent control that should be used on every page where we want to use other controls of the AJAX. A standard code for ScriptManager control will look like following:
<asp:ScriptManager ID="scriptmgr1" runat="Server" EnablePartialRendering="True" />

Can we use multiple ScriptManager on a page?
No. We can use only one ScriptManager on a page.

About the UpdatePanel:
The UpdatePanel enables you to add AJAX functionality to existing ASP.NET applications. It can be used to update content in a page by using Partial-page rendering. By using Partial-page rendering, you can refresh only a selected part of the page instead of refreshing the whole page with a postback.

The UpdatePanel has two child tags
one is ContentTemplate and another is Triggers


Custom Search
Protected by Copyscape Plagiarism Software