Tuesday, November 16, 2010

Difference between new Operator and Modifier

• new operator Used to create objects on the heap and invoke constructors.

• new modifier Used to hide an inherited member from a base class member.

Example for new modifier:


Tuesday, November 9, 2010

tic tac toe

Create design for tic tac toe game. Draw use case diagram, class diagram & write the pseudo code of the logic.

Nested class

namespace NestedClass
{
class Program
{
static void Main(string[] args)
{
A a = new A();

A.AA aa = new A.AA();

}
}

public class A
{
public class AA
{
public int i = 10;
A x = new A();
A.AA xx = new AA();
}
}
}

Application state in ASP.NET

  • Application is a server side state mechanism in ASP.NET.
  • It is a global way to store data in ASP.NET applications.
  • It stores as key/value pair.
  • application state is an instance of HttpApplicationState class
http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx

Different state management techniques in ASP.NET

client side state management techniques:

  1. ViewState
  2. ControlState
  3. Cookies
  4. Hidden fields

Server side state management techniques

  1. Session
  2. Application
Reference: http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx

String is a reference type. In the below code, what would be the output?

class Program
{
static void Main(string[] args)
{
string s = "abc";
CallMethod(s);
Console.WriteLine(s);
Console.Read();

}
static void CallMethod(string s)
{
s = "xyz";
}
}

Output: abc

difference between server.transfer and response.redirect

Both Respone.Redirect and Server.Transfer open up another page, but the interaction between client(browser) and server(asp.net) differs in each situation.

Resonse.Redirect simply tell the browser to visit another page.
Its the reponsibility of the browser to open up the another page.
External sites can be opened.

Server.Transfer works for only sites which runs on the server.
External sites cannot be opened.
Sharing states between pages is much easier using Server.Transfer.
Server.Transfer keeps the URL the same. This may lead to confusion.