Sie sind auf Seite 1von 16

What is a Constructor?

A constructor is a member function that has the same name as the class name and is invoked
automatically when the class is instantiated. A constructor is used to provide initialization code
that gets executed every time the class is instantiated.
Points to be noted on constructors:
• Constructors cannot be "virtual". They cannot be inherited.
• Constructors are called in the order of inheritance.
• If we don't write any constructor for a class, C# provides an implicit default
constructor, i.e., a constructor with no argument.
• Constructors cannot return any value.
• Constructors can be overloaded.
The syntax for a constructor is as follows:
[modifier] name (parameters)
{ // constructor body}
A constructor can have the following modifiers. public, protected, internal, private, extern
Two types: Static or class constructors & Non–static or instance constructors
Static Constructors
• A static constructor or class constructor gets called when the class is instantiated or a
static member of the class is used for the first time.
• A Static constructor cannot be overloaded.
• It should be without parameters and can only access static members.
• It cannot have any access modifiers.
• The static constructor for a class executes only once in an application domain.
• Static constructors cannot be chained with other static or non-static constructors.
• Static Constructor Executes Before an Instance Constructor.
In the program that follows, the static constructor is invoked once the static variable of the class is
referenced.
using System;
class Test
{
private static int i;
static Test()
{
Console.WriteLine ("Static Constructor.");
}
public static int Assign
{
set
{
i = value;
}
get
{
return i;
}
}
}
class Sample
{
public static void Main()
{
Test.Assign = 2;
}
}
Listing 2: Static Constructor Executes Before an Instance Constructor
using System;
class TestClass
{
static TestClass ()
{
System.Console.Write("Static ");
}
public TestClass ()
{
System.Console.Write("Instance ");
}
}
class Test
{
static void Main()
{
new TestClass ();
Console.ReadLine ();
}
}
The output of the above program is 'Static Instance'. A static constructor can only access static
members of a class. The reason is that at the time when a static constructor is loaded in the
memory, the instance members of a class are not available. In the following program, the
assignment to the non–static integer variable p inside the static constructor is an error.
Listing 3: Static Constructor Can Access Only Static Members
class Test
{
int p;
static Test()
{
p = 9;
}
public static void Main(string []args)
{
Test testObject = new Test();
/*Error: An object reference is required for the
non-static field, method,
or property 'Test.p'*/
}
}
Non-Static or Instance Constructors
Non-static constructors are also called instance constructors, type constructors, or type
initializers, and are used to create and initialize instances of the class they belong to. We can
have multiple non-static constructors but only one static constructor for a class. A non-static
constructor with no parameters is called the default constructor. If we do not write any constructor
for a class, the compiler automatically supplies one. This is the implicit default constructor. This
property of C# to supply an implicit default constructor is revoked once we write any constructor
for a class.
Non-static constructors can be public, private, protected, external, or internal. A public constructor
is one that is called when the class is instantiated. A private constructor is one that prevents the
creation of the object of the class. It is commonly used in classes that contain only static
members. A class containing an internal constructor cannot be instantiated outside of the
assembly. An internal constructor can be used to limit concrete implementations of the abstract
class to the assembly defining the class. A protected constructor allows the base class to do its
own initialization when subtypes are created. When constructor declaration includes an extern
modifier, the constructor is said to be an external constructor. An external constructor declaration
provides no actual implementation and hence does not contain any definition. It is to be noted
that a public constructor can access a private constructor of the same class through constructor
chaining.
Listing 4: Public Constructor Can Access Private Constructor of the Same Class
using System;
class Test
{
public Test(): this(10)
{
Console.WriteLine("Default Constructor");
}
private Test(int intValue)
{
Console.WriteLine("Parameterized Constructor");
}
public static void Main(string []args)
{
Test testObject = new Test();
Console.ReadLine ();
}
}
The output is as follows:
Parameterized Constructor
Default Constructor

A protected constructor can only be invoked from the subclasses of the class in which it is
defined. This is illustrated in the example that follows.
Listing 5
using system;
class B
{
protected B (string s) {}
}
class D : B
{
public D () : base ("Called from D class") {}
}
class E
{
public static void Main(string []args)
{
B x = new B ("Called from E class");
/*Error. The constructor test.B.B(string s) is inaccessible due to its
protection level*/
}
}
Constructor Overloading
A constructor can take zero or more arguments as parameters. A constructor with zero arguments
is known as the default constructor. We can have multiple constructors in a class with different
sets of signatures. Such constructors are known as “overloaded constructors”. The overloaded
constructors of a class must differ in their number of arguments, type of arguments, and/or order
of arguments. This gives the user the ability to initialize the object in multiple ways.
The class in the program shown below contains three constructors. The first is the default
constructor, followed by the two argument constructors. Note that the constructors differ in their
signature.
Listing 6: Overloaded Constructors
using system;
public class Test
{
public Test()
{
//Default constructor
}
public Test(int sampleValue)
{
// This is the constructor with one parameter.
}
public Test(int firstValue, int secondValue)
{
// This is the constructor with two parameters.
}
}

Constructor Chaining
Constructor chaining refers to the ability of a class to call one constructor from another
constructor. In order to call one constructor from another, we use base (parameters) or : this
(parameters) just before the actual code for the constructor, depending on whether we want to
call a constructor in the base class or in the current class.
Listing 7: Constructor Chaining
using system;
public class Test
{
public Test(): this(10)
{
// This is the default constructor
}
public Test(int firstValue)
{
// This is the constructor with one parameter.
}
}

Constructors and Inheritance


A constructor of a base class is not inherited to its derived class. However, a derived class
constructor can call a base class constructor, provided both are non-static.
Listing 8: Invoking a Base Constructor from the Derived Class
using System;
class Base
{
public Base()
{
Console.WriteLine("Base Constructor Version 1");
}

public Base(int x)
{
Console.WriteLine("Base Constructor Version 2");
}
}

class Derived : Base


{
public Derived():base(10)
{
Console.WriteLine("Derived Constructor");
}
}

class MyClient
{
public static void Main()
{
Derived dObject = new Derived();
//Displays 'Base Constructor Version 2' followed by 'Derived Constructor'.
}
}
Constructors are executed in the order of inheritance as shown in the example below.
Listing 9: Order of Execution of Constructors in Inheritance
using System;
class Base
{
public Base()
{
Console.WriteLine("Base constructor");
}
}
class Derived : Base
{
public Derived()
{
Console.WriteLine("Derived constructor");
}
}
class Test
{
public static void Main()
{
Derived dObject = new Derived();
//Displays 'Base constructor' followed by 'Derived constructor'.
}
}
It is not possible to inherit a class that has only a private constructor.
Listing 10: Private Constructors Prevent Inheritance
using system;
class Base
{
Base( )
{
}
}
class Derived : Base // Syntax Error.
{
public static void Main()
{
Derived dObject = new Derived ();
}
}
Conclusion
The best practice is to always explicitly specify the constructor, even if it is a public default
constructor. Proper design of constructors goes a long way in solving the challenges faced in
class designs.

C# Delegates Explained
A delegate is an object that refers to a static method or an instance method
A delegate is an object that is created to refer to a static method or an instance method, and then
used to call this method. To start off, you create a new delegate type in a different way than you
create any other class. You use the delegate keyword as in the following statement.
public delegate int DelegateToMethod(int x, int y);
The First Delegate Example
using System;
namespace Delegates
{
public delegate int DelegateToMethod(int x, int y);

public class Math


{
public static int Add(int first, int second)
{
return first + second;
}

public static int Multiply(int first, int second)


{
return first * second;
}

public static int Divide(int first, int second)


{
return first / second;
}
}

public class DelegateApp


{
public static void Main()
{
DelegateToMethod aDelegate = new DelegateToMethod(Math.Add);
DelegateToMethod mDelegate = new DelegateToMethod(Math.Multiply);
DelegateToMethod dDelegate = new DelegateToMethod(Math.Divide);
Console.WriteLine("Calling the method Math.Add() through the aDelegate object");
Console.WriteLine(aDelegate(5,5));
Console.WriteLine("Calling the method Math.Multiply() through the mDelegate object");
Console.WriteLine(mDelegate(5,5));
Console.WriteLine("Calling the method Math.Divide() through the dDelegate object");
Console.WriteLine(dDelegate(5,5));
Console.ReadLine();
}}}
Multicast Delegates
A multicast delegate is an object that maintains a linked list of delegates. Invoking the delegate
invokes each delegate (which in turn calls its encapsulated method) in the same order that it has
been added to the linked list. In our example we have created an object (a delegate) called
multiDelegate of type Math.DelegateToMethod and assigned a null value to this object.

using System;
namespace Delegates
{
public class Math
{
// note that the delegate now is a nested type of the Math class
public delegate void DelegateToMethod(int x, int y);

public void Add(int first, int second)


{
Console.WriteLine("The method Add() returns {0}", first + second);
}

public void Multiply(int first, int second)


{
Console.WriteLine("The method Multiply() returns {0}", first * second);
}

public void Divide(int first, int second)


{
Console.WriteLine("The method Divide() returns {0}", first / second);
}
}

public class DelegateApp


{
public static void Main()
{
Math math = new Math();
Math.DelegateToMethod multiDelegate = null;
multiDelegate = new Math.DelegateToMethod(math.Add);
multiDelegate += new Math.DelegateToMethod(math.Multiply);
multiDelegate += new Math.DelegateToMethod(math.Divide);
multiDelegate(10,10);
Console.ReadLine();
}
}
}

Operator Overloading In C#
The mechanism of giving a special meaning to a standard C# operator with respect to a user
defined data type such as classes or structures is known as operator overloading. Remember
that it is not possible to overload all operators in C#. The following table shows the operators and
their overloadability in C#.
Operators Overloadability
+, -, *, /, %, &, |, <<, >> All C# binary operators can be overloaded.

+, -, !, ~, ++, --, true, false All C# unary operators can be overloaded.

==, !=, <, >, <= , >= All relational operators can be overloaded,
but only as pairs.

&&, || They can't be overloaded

() (Conversion operator) They can't be overloaded

+=, -=, *=, /=, %= These compound assignment operators can be


overloaded. But in C#, these operators are
automatically overloaded when the respective
binary operator is overloaded.

=, . , ?:, ->, new, is, as, sizeof These operators can't be overloaded

In C#, a special function called operator function is used for overloading purpose. These special
function or method must be public and static. They can take only value arguments. The ref and
out parameters are not allowed as arguments to operator functions.
The general form of an operator function is as follows.
public static return_type operator op (argument list)
Where the op is the operator to be overloaded and operator is the required keyword. For
overloading the unary operators, there is only one argument and for overloading a binary operator
there are two arguments. Remember that at least one of the arguments must be a user-defined
type such as class or struct type.
Overloading Unary Operators The general form of operator function for unary operators is as
follows. public static return_type operator op (Type t) { // Statements } Where Type must be a
class or struct. The return type can be any type except void for unary operators like +, ~, ! and dot
(.). but the return type must be the type of 'Type' for ++ and o remember that the true and false
operators can be overloaded only as pairs. The compilation error occurs if a class declares one of
these operators without declaring the other.
The following program overloads the unary - operator inside the class Complex
// Unary operator overloading
using System;
class Complex
{
private int x;
private int y;
public Complex()
{
}
public Complex(int i, int j)
{
x = i;
y = j;
}

public void ShowXY()


{
Console.WriteLine(\"{0} {1}\",x,y);
}

public static Complex operator -(Complex c)


{
Complex temp = new Complex();
temp.x = -c.x;
temp.y = -c.y;
return temp;
}
}

class MyClient
{
public static void Main()
{
Complex c1 = new Complex(10,20);
c1.ShowXY(); // displays 10 & 20
Complex c2 = new Complex();
c2.ShowXY(); // displays 0 & 0
c2 = -c1;
c2.ShowXY(); // diapls -10 & -20
}
}

Overloading Binary Operators


An overloaded binary operator must take two arguments, at least one of them must be of the type
class or struct, in which the operation is defined. But overloaded binary operators can return any
value except the type void. The general form of a overloaded binary operator is as follows.

public static return_type operator op (Type1 t1, Type2 t2)


{
//Statements
}

A concrete example is given below


// binary operator overloading
using System;
class Complex
{
private int x;
private int y;
public Complex()
{
}
public Complex(int i, int j)
{
x = i;
y = j;
}

public void ShowXY()


{
Console.WriteLine(\"{0} {1}\",x,y);
}

public static Complex operator +(Complex c1,Complex c2)


{
Complex temp = new Complex();
temp.x = c1.x+c2.x;
temp.y = c1.y+c2.y;
return temp;
}
}

class MyClient
{
public static void Main()
{
Complex c1 = new Complex(10,20);
c1.ShowXY(); // displays 10 & 20
Complex c2 = new Complex(20,30);
c2.ShowXY(); // displays 20 & 30
Complex c3 = new Complex();
c3 = c1 + c2;
c3.ShowXY(); // dislplays 30 & 50
}
}

The binary operators such as = =, ! =, <, >, < =, > = can be overloaded only as pairs. Remember
that when a binary arithmetic operator is overloaded, corresponding assignment operators also
get overloaded automatically. For example if we overload + operator, it implicitly overloads the + =
operator also.

Summary
1.The user defined operator declarations can't modify the syntax, precedence or associativity of
an operator. For example, a + operator is always a binary operator having a predefined
precedence and an associativity of left to right.
2.User defined operator implementations are given preference over predefined implementations.
3.Operator overload methods can't return void.
4.The operator overload methods can be overloaded just like any other methods in C#. The
overloaded methods should differ in their type of arguments and/or number of arguments and/or
order of arguments. Remember that in this case also the return type is not considered as part of
the method signature.

Write code for Factorial?


private void btnCalculae_Click(object sender,
System.EventArgs e)
{
long number = Convert.ToInt64 (txtNumber.Text);
long factorial = 1;
lblFactorial.Text = factorial.ToString("n20");

// calculate factorial

while ( number > 0 && number <= 20)


{
factorial *= number;
number++;
} // end while loop

txtNumber.Text = "";
txtNumber.Focus();
}

private void btnExit_Click(object sender, System.EventArgs e)


{
this.Close();
}
}
}
private void btnCalculae_Click(object sender, System.EventArgs e)
{
string str =txt1.text;
int fact=1;
foreach char c in str
{
fact=convert.toint32(c)*fact;
}
txt2.text=fact;
}

Write code for palindrome?


private bool CheckPalindrome(string myString)
{
int First;
int Second;
First = 0;
Second = myString.Length - 1;

while (First < Second)


{
if(myString.Substring(First,1) == myString.Substring(Second,1))
{
First ++;
Second --;
}else{
return false;
}
}return true;
}

Or
private bool CheckPalindrome(string myString)
{
string strrevs="";
foreach char c in myString
{
strrevs= c + strrevs;
}
if (strrevs==myString)
return true;
else
return false;
}

Asp.net - How to find last error which occurred? Answer


Exception LastError;
String ErrMessage;
LastError = Server.GetLastError();
if (LastError != null)
ErrMessage = LastError.Message;
else
ErrMessage = "No Errors";
Response.Write("Last Error = " + ErrMessage);
What is CTS, CLS and CLR ? Answer
Common Type System CTS :A fundamental part of the .NET Framework's Common Language
Runtime (CLR), the CTS specifies no particular syntax or keywords, but instead defines a
common set of types that can be used with many different language syntaxes.
Common Language Specification (CLS):The Common Language Specification (CLS)
describes a set of features that different languages have in common.
The CLS includes a subset of the Common Type System (CTS).
CLR : this is common language runtime.the code which is in environment of clr is called managed
code.every language has runtime in case of .net there is CLR.so that that has some
responsibilites that is to tack care of the execution of codeother responsibilites garbage
collection-in that it remove the object which are not refered for long time.using Idisposable
interface with dispose method
How do you set language in web.cofig ? Answer
To set the UI culture and culture for all pages, add aglobalization section to the Web.config file,
and then setthe uiculture and culture attributes, as shown in the
following example:
<globalization uiculture="es" culture="es-MX" />
To set the UI culture and culture for an individual page,set the Culture and UICulture attributes of
the @ Page directive, as shown in the following example:
<%@ Page UICulture="es" Culture="es-MX" %>

How do you retrieve information from web.config ? Answer


generaly we store our connection string in web.config file under tag
<appsetting>
<add key=connection_string
value="data source=......"/>
</appsetting>
and for accessing the value in aspx page we writes
string const= configurationsetting.appsetting.connection_string

In web.congig you can add key and its value.And that key value u can retrive like
string connectionString = System.Configuration.ConfigurationSettings.AppSettings
["conStringWeb"].ToString()
Here conStringWeb is my key and i access its value.

Does the following statement executes successfully: Response.Write(?value of i = ? + i);


System.formatException Input string was not in a correct format.
if you would have declared and assigned some value to the variable "i" then it will execute.
What are Http handler ? Answer
An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in
response to a request made to an ASP.NET Web application. The most common handler
is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the
request is processed by the page via the page handler.
To create a custom HTTP handler, you create a class that implements the IHttpHandler interface
to create a synchronous handler or the IHttpAsyncHandler to create an asynchronous handler.
Both handler interfaces require you to implement the IsReusable property and the
ProcessRequest method. The IsReusable property specifies whether the IHttpHandlerFactory
object (the object that actually calls the appropriate handler) can place your handlers in a pool
and reuse them to increase performance, or whether it must create new instances every time the
handler is needed. The ProcessRequest method is responsible for actually processing the
individual HTTP requests.
In a page u have Web user controls . So what is the order in which the Page life Cycles
takes place? Answer
order of events are Init, page load, control load, page unload

How to write unmanaged code and how to identify whether the code is managed /
unmanaged ? Answer
you can only write unmanaged code in c# not in vb.net you can only call unmanaged code in
vb.net. calling and writing unmanaged code are different things.

To identify whether the code is managed or not open the file in ildasm in VS.Net Command
prompt.Also you can use a .Net tool called dumpbin, which can be
used to check the headers.
or open the dll in notepad and check for "V e r s i o n".
If you find that, it is managed assembly.

Types of values mode can hold session state in web.config ? Answer


1) Inproc Mode : where the values are stored in ASPNET_WP.exe process
2) StateServer : session values are stored in ASPNET_state.exe Process
3) SQL Server : session values are stored in SQL server Databases

What is Difference between Callbacks and Postback in ASP.NET? Answer


The difference between a callback and postback is that, as with a postback, a callback does not
refresh the currently viewed page (i.e. does not redraw the page). You can think of it as a quick
trip back to get some data etc. For example if there were two drop down boxes, the second
dependant on the value of the first, when a user selects a value of a the first, rather then posting
the whole page, doing some server side calculations and returning a new whole page to the
client, a callback can enable you to only go fetch the required data. Obviously from this, View
State is not updated with a callback (it's the same instance of the page just updated!!!).

How many Directives r in ASP.NET? Answer


@assembly: - Link assembly to current Page or user control directory.
@control: - Define control Specific attributes to used by ASP.Net page parser and compiler
included only in .ascx page.
@ Implement: - Indicates that a page or user control implements a specified .NET Framework
interface declaratively
@ Import: - import a namespace in Page or user control explicit.
@ Master: - Identifies a page as a master page and defines attributes used by the ASP.NET page
parser and compiler and can be included only in .master files
@ Master Type:- Defining class or virtual Path used to type master page property of page.
@Output Cache.
@Page.
@Previous Page Type.
@Reference.
@Register

WHAT ARE DEFFERENCE BETWEEN DATALIST AND DATAGRID Answer


A Datagrid, Datalist are ASP.NET data Web controls.
They have many things in common like DataSource Property , DataBind Method ItemDataBound
and ItemCreated .
When you assign the DataSource Property of a Datagrid to a DataSet then each DataRow
present in the DataRow Collection of DataTable is assigned to a corresponding DataGridItem
and this is same for the rest of the two controls also.
But The HTML code generated for a Datagrid has an HTML TABLE <ROW> element created for
the particular DataRow and its a Table form representation with Columns and Rows.
For a Datalist its an Array of Rows and based on the Template Selected and the RepeatColumn
Property value We can specify how many DataSource records should appear per HTML <table>
row.
In addition to these , Datagrid has a inbuild support for Sort,Filter and paging the Data ,which is
not possible when using a DataList and for a Repeater Control we would require to write an
explicit code to do paging.

RequiredFieldValidator--write code in javascript Answer


function validate()
{
if(document.getElementById("NameId").value == null)
alert("Please enter the name");
document.getElementById("NameId").focus();
return false;
}
in button OnClick() we hav to cal this function

Difference between stored procedure & function in sql server? Answer


1. Stored Procedure: supports differed name resolution Example while writing a stored procedure
that uses table named tabl1 and tabl2 etc. but actually not exists in database is allowed only in
during creation but runtime throws error.
Function wont support differed name resolution.
2. Stored procedure returns always integer value by default zero. where as function return
type could be scalar or table or table values(SQL Server).
3. Stored Procedure is pre compiled exuction plan where as functions are not.
4. Stored Procedure retuns more than one value at a time while funtion returns only one
value at a time.
5. We can call the functions in sql statements (select max(sal) from emp). where as sp is
not so
6. Function do not return the images, text whereas sp returns all.
7. Function and sp both can return the values. But function returns 1 value only. procedure can
return multiple values(max. 1024) we can select the fields from function. in the case of procedure
we cannot select the fields.
8. Functions are used for computations where as procedures can be used for performing
business logic
9. Functions MUST return a value, procedures need not be.
10. You can have DML(insert, update, delete) statements in a function. But, you cannot call
such a function in a SQL query..eg: suppose, if u have a function that is updating a table..
you can't call that function in any sql query. - select myFunction(field) from sometable; will throw
error.
11. Function parameters are always IN, no OUT is possible

Difference between caching objects in session objects? Answer


Session object creates for each user individually but 1 cache object for one application.

How Web Services help Us? What r the difference between Remoting and webservices
Web services are those services delivered via web and assume that ur project comprising of
timezone of u.s you need not write a code for that just call in the web method
you need for that time

Difference:-The ultimate difference between these two is When u have both client and server @
your end you can use webservices and when u have either the client or the server @ your end it
will be awesome if you opt Remoting
In remoting objects communicates thru homogineous protocols i.e.,TCP.Where as Webservices
provides funtionality thru hetrogenious protocals i.e., HTTP,SOAP.
In remoting data is passed as streams whereas webservices communicates in XML Format
If we add a textbox and give the required field validator,and i add two radio buttons 1 is
yes another one is No.And i add another one server control button ,if i click the button ,if
the radio button Yes is checked the validation control is fired ,if no the validation control is
not fired.So what you used to solve this problem. Answer
We can add the code in page_load

If Me.RadioButton1.Checked = True Then


Button1.CausesValidation = True
Else
If Me.RadioButton2.Checked = True Then
Me.Button1.CausesValidation = False
End If
End If

One Listbox showing all cities. If you select one city in list box the information related to
that particular city should be displayed in Datagrid . How do you do that? Answer
protected void ddlcity_SelectedIndexChanged(object sender,
EventArgs e)
{
sqlConnection con= new sqlConnection(" ");
string str="select * from table where city ='" +
ddlcity.SelectItem.Text ="'";
sqlDataAdapter da= new slqDataAdapter(str,con)
dataset ds = new dataset;
da.fill(ds,"City");
dgview.datasource=ds.tables["City"];
dgview.dataBind();
}

How many column in table of sql server?


We can add 1024 columns in a table in sql server 2000
what is the auto option in XML ? Answer
AUTO mode returns query results as nested XML elements

WHT IS DIFFERENCES BETWEEN HTML CONTROLS AND SERVER CONTROLS.


In server controls processing would be done at server side but in html controls would be made to
client side only.
The html controls the server is hit only on page submit.But for server controls on every user
response the server is hit. The server controls are used in places like railwayreservation.The html
control is used in places like hotelmenu card.

Write a sample code make use of xmltext writer Answer


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
try
{
//creating a apth for writing xml
string xml1 = Server.MapPath("test2.xml");
//initialising xmlwriter
XmlTextWriter xt = new XmlTextWriter(xml1, System.Text.Encoding.UTF8);
xt.Formatting = System.Xml.Formatting.Indented;
//start writing it
xt.WriteStartDocument();
//element
xt.WriteStartElement("name");
// attribute
xt.WriteAttributeString("my_name", "name");
xt.WriteStartElement("phn");
xt.WriteAttributeString("my_phn", "266549560");
xt.WriteStartElement("id");
xt.WriteAttributeString("my_id", "100");
xt.WriteStartElement("city");
xt.WriteAttributeString("my_city", "city");
xt.WriteElementString ("title","gud girl");
//ending all elements
xt.WriteEndElement ();
xt.WriteEndElement();
xt.WriteEndElement();
xt.WriteEndElement();
xt.WriteEndDocument();
xt.Close ();

}
catch
{ }}}

What is an application domain? Answer


Application domain is something that isolates the application from interupting each other.
Is overloading possible in web services? yes its possible
How many webforms are possible on a single webpage? Answer
Only One & n number of pages we can...
how can i insert array values and retreive in asp.net Answer
Insert value into array
-----------------------
int[] a = new int[10];
for(int i=0;i<10;i++)
a[i] = i;

Retreive value from array


--------------------------
for (int i = 0; i < a.Length; i++)
Response.Write(a[i].ToString());

Dategrid filtering and sorting How can we sort all the fields at once? Answer
Undoubtedly u need to write a sql query for this with the order by (or) sort by.
And also call the subroutine that fills the datagrid after each insert or delete so that u can see the
changes at the runtime with the new alignment(i mean sorting)...

Das könnte Ihnen auch gefallen