Tuesday, April 28, 2009

How to convert a sentence into Title Case (Capitalize first character of every word)?

Use ToTitleCase method.

System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase("dotnetfunda.com is a very good website");

The output will be "Dotnetfunda.Com Is A Very Good Website"
//////////////////////////////////////////////////////////////////////////////////////
Use the namespace System.Globalization

string myString = "syncFusion deVeloPer sUppOrt";
// Creates a TextInfo based on the "en-US" culture.
TextInfo TI = new CultureInfo("en-US",false).TextInfo;
Response.Write (TI.ToTitleCase( myString ));

How to display data in Textboxes using DataSet?

//Populate the DataSet

//Display in TextBoxes using Column Name
TextBox1.Text = ds.Tables [0].Rows[0]["ProductId"].ToString ();
TextBox2.Text =ds.Tables [0].Rows[0]["ProductName"].ToString ();


//Display in TextBoxes using Column Index
TextBox1.Text = ds.Tables [0].Rows[0][0].ToString ();
TextBox2.Text =ds.Tables [0].Rows[0][1].ToString ();

Difference between DropDownList.Items.Add and DropDownList.Items.Insert method

DropDownList.Items.Add method allows you to add new ListItem into the DropDownList. This item will be added as the last item of the DropDownList.

dropDownList.Items.Add(new ListItem("Default Panel", "0"));


DropDownList.Items.Insert method allows you to specify the index of the item within the DropDownList where you want to insert the ListItem.

dropDownList.Items.Insert(0, new ListItem("Default Panel", "0"));
Here Default Value will be added as the first item in the DropDown.

convert TextBox value into a DateTime variable

DateTime dt = DateTime.Parse(TextBox1.Text);

FAQ'S

What is the difference between Session.Abandon() and Session.Clear()?
The major practical difference is that if you call Session.Abandon(), Session_End will be fired (for InProc mode), and in the next request, Session_Start will be fired. Session.Clear( ) just clears the session data without killing it.

Themes:A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in a Web application, across an entire Web application, or across all Web applications on a server.

The drawback to the DataGrid's built-in paging functionality:With each page change a PostBack event fires and the data source is recreated and re-bound to the DataGrid.The entire data source, not just the single page being displayed. If the table you are paging through has one million records in it, all one million records are queried, transported to the application, and then a select few (the current page) are displayed,where you may run into a slight performance issue with this.

What is the Main difference between String and StringBuilder and why do we use StringBuilder.
String bulider Can Be Used When More Than One String Can we concatenated.
StringBuilder which is more efficient because it does contain a mutable string buffer. .NET Strings are immutable
which is the reason why a new string object is created
every time we alter it (insert, append, remove, etc.).
StringBulider Is more Effiecent Then String B'Cuse It
Provide Some Standered Function like Append,Reverse,Remove
etc.


can machine.config file orverrides web.config. For example: if u set session timeout as 30 mins in web.config file to a particular application and if u set session timeout as 10 mins in machin.config. what will happen and which session is set to the appliction?
As the Web.Config file defines application level settings.It'll override the settings of the machine.configfile.So the session timeout as 30 mins defined in web.configfile is set to the application.

How is a property designated as read-only?
in C#
public returntype PropertyName
{
get{
//property implementation goes here
}
// Do not write the set implementation
}

Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.

Can we use Truncate command on a table which is referenced by FOREIGN KEY?
No. We cannot use Truncate command on a table with Foreign Key because of referential integrity.

What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.

Serialization:
Serialization is the process of converting an object into a stream of bytes in order to persist it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.

What is abstract class ? when is used in real time ?
An Abstract Class is one in which the member function(s) at the Base(Parent) Class are left undefined, but declared. It's upto the Derived(child(ren)) Classes to Implement the Functions declared in Base...
Ex:
Let us assume... As a father(Base Class), he has some Land (Member Function), and he has not done any cultivation (implementation) in it... As his Child(Derived Class), he takes the Land(Member Function) from the Father(Base) and does Agriculture(implementing the M.F. of Parent Class) in the Child...
Do I need IIS to run Web applications?
If you are using Visual Studio, you can use the ASP.NET Development Server built into Visual Studio to test your pages. The server functions as a local Web server, running ASP.NET Web pages in a manner virtually identical to how they run in IIS. To deploy a Web application, you need to copy it to a computer running IIS version 5 or 6.


Difference between Set and Select

Set is a ANSI standard for variable assignment.

Select is a Non-ANSI standard when assigning variables.

We can assign only one variable at a time

We can assign multiple variable at a time

When assigning from a query that returns more than one value, SET will fail with an error.

When assigning from a query that returns more than one value, SELECT will assign the last value returned by the query and hide the fact that the query returned




10 Important .NET OOP interviews questions

What's the most asked question in OOP from Interviews perspective?

If you are fresher you will be asked the Why OOP's and the 4 important properties of OOP's programming. Interviewers will then drill down on specific property like encapsulation or abstraction and ask some questions around the same.

If you are experienced professional like 5 yrs and above , he or she will start from your project architecture and then indirectly ask questions like how did you decouple the UI from the business object , how was your class design etc.

How did you implement encapsulation in C# ?

By declaring the properties as privat*e and then using public set and get to wrap those privat*e properties.

What's the difference between abstraction and encapsulation?

Abstraction is a thought process or design approach where we expose only what?s necessary while encapsulation is the process to hide complexity. Encapsulation is way of implementing abstraction. In this question interviewer will try to take you for a ride as abstraction and encapsulation complement each other.

What's the difference between abstract class and interface?

An abstract class can have abstract member?s as well non abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must override to its derived class.

The members of the interface are public with no implementation. Abstract classes can have protected parts, static methods, etc.

Abstract classes can add more functionality without destroying the child classes that were using the old version. In an interface, creation of additional functions will have an effect on its child classes, due to the necessary implementation of interface methods to classes.

Defining an abstract class with abstract members has the same effect to defining an interface.

Can we create an object of interface or abstract class?

No.

What are the 2 different types of polymorphism?

Static and dynamic polymorphism.

How can we implement
Few more question:
1.When to use abstract class and when to use Interface?
2.How will you handle a situation where a class implements two interface having same method name and signature?
3.Can I declare an empty class as abstract?
4.Can a sealed class have virtual method?
5.When u create a parameterized constrcutor then does the default constructor gets created automatically?
6. A
/|\
|
B
/|\
|
C

Is the protected member of A accessible in class C?

Displaying date in dd/mm/yyyy format

TextBox1.Text=DateTime.Now.ToString("dd/MM/yyyy");

for further info:

Monday, April 27, 2009

Display Right-to-Left Text in aTextBox

To enter data from right to left in a TextBox,use "dir=rtl" property.
2nd method:
TextBox1.Style["text-align"] = "right";

Retrieving Data from SQL Server Database in XML Format

SELECT * FROM FOR XML AUTO/RAW/EXPLICIT/NESTED

Apart from these there are optional parameters for the SQL query. The optional parameters as the name indicates can either be used or neglected. The optional parameters that can be used are Binary Base64, Elements, and XMLData. With the optional parameters in place the syntax would take the form,

SELECT ... FOR XML mode [, BINARY BASE64] [, ELEMENTS] [, XMLDATA]

The Binary Base64 option is used if you want to retrieve data in the binary format from the database. Binary data that is found in the database should be retrieved using this option. The modes that are used to retrieve data in binary format are the ‘raw’ and the ‘explicit’ modes.

The Elements option is used to return the data in the table as child elements. The fields of the row become the attributes of the element returned if you are not using the Elements option. Thus for each row you get an element with child elements being the fields of the row.

Auto mode is the only mode in which you can use the Elements option. If you want to define the format that is returned you need an XSD schema for that. The XMLData option allows this. This option adds a schema so that you get the format that you want for your XML data.

example:

select * from employee for xml auto

select * from employee for xml auto,elements

Fore more info:http://www.xml-training-guide.com/retrieve-sql-server-data-in-xml-format.html



Saturday, April 25, 2009

Swapping Values between two variables without using temp variable

There is an easy way to swapping values of two variables by using a temporary variable. But here am trying to get interchanged values between those variables without using any temporary variable. Just look in to this…


public int a = 10;

public int b = 20;


//Before swapping

textBox1.Text = a.ToString();

textBox2.Text = b.ToString();

//After swapping

a = a + b;

b = a - b;

a = a - b;

textBox1.Text = a.ToString();

textBox2.Text = b.ToString();

//For strings

String name1 = "Hello";

String name2 = "World";

name1 = name1 + name2;

name2 = name1.Substring(0, (name1.Length - name2.Length));

name1=name1.Substring(name2.Length);

Response.Write(name1);

Response.Write(name2);