Saturday, October 25, 2008
To make a property, indexer readonly
class A
{
string s = "Welcome to C#";
public char this [int index]
{
get { return s[index];
} }
public string GetS
{
get { return s; }
}}
To use this
A obj = new A();
char c = obj[3];
obj[3] = 'a'; //Errorstring
s = obj.GetS;
obj.GetS = "Good Day"; //Error
Tuesday, October 21, 2008
MCTS 70-431 Exam
Total Marks : 1000
Pass Mark : 700
Time : 205 min (180 min for exam and 25 min for instructions)
Exam Fee : 50$
The following are the list of useful materials to begin with,
Refer this link for MSDN Virtual labs http://msdn2.microsoft.com/en-us/virtuallabs/aa740409.aspx
The New Generation of Microsoft Certifications http://www.microsoft.com/learning/mcp/newgen/default.mspx
Microsoft Next Generation of Certifications: Frequently Asked Questions http://www.microsoft.com/learning/mcp/newgen/faq/default.mspx
Microsoft Certifications for IT Professionals http://www.microsoft.com/learning/mcp/mcitp/default.mspx
SQL Server 2005 DBA Street Smarts http://www.sybex.com/WileyCDA/SybexTitle/productCd-0470083492.html
MCTS 70-431 Self placed Training Kit http://www.microsoft.com/MSPress/books/9364.aspx
Thursday, October 16, 2008
Why can not you specify accessibility modifier in Interface
So Interfaces members are automatically public.
In this context public only valid. Other modifier private, protected are may not be useful for the global communication.
Ex
public interface Runnable {
void run ();
}
This run function is automatically public
To implement the interface
class A :Runnable {
public void run () {
// Some Codes
}
}
Saturday, October 11, 2008
Anonymous method
Ananymous methos are the usual delegate methods, but without a Name for that method.
class SomeClass
{
delegate void SomeDelegate();
public void InvokeMethod()
{
SomeDelegate del = delegate()
{
MessageBox.Show("Hello");
};
del();
}
}
Passing Parameters to Anonymous Methods
When defining an anonymous method with parameters, you define the parameter types and names after the delegate keyword just as if it were a conventional method. The method signature must match the definition of the delegate to which it is assigned. When invoking the delegate, you pass the parameter's values, just as with a normal delegate invocation:
class SomeClass
{
delegate void SomeDelegate(string str);
public void InvokeMethod()
{
SomeDelegate del = delegate(string str)
{
MessageBox.Show(str);};
del("Hello");
}
}
Friday, October 10, 2008
Is Inheritance possible in Static class
Static classes allows to create data and functions that can be accessed without creating an instance of the class. Static class members can be used to separate data and behavior that is independent of any object:
It is useful when there is no data or behavior in the class that depends on object identity
The main features of a static class are:
> They only contain static members.
> They cannot be instantiated.
> They are sealed.
> They cannot contain Instance Constructors
Because of "static classes are sealed" they cannot be inherited.
Thursday, October 2, 2008
Is it possible to implement an interface to a structure. Is it possible to extend a struct. Is it possible to inherit a class to struct.
It is possible to implement an interface to a Structure
public interface ISpeak
{
void Say();
}
public struct A:ISpeak
{
public void Say()
{
}
}
But a struct cannot inherit from any type it can only implement the interface. Also a class cannot be inherited form a structure. by default a struct is sealed.
Generics
Example
class List
{
T[] tmp = new T[10];
}
class MyClass
{
static void Main(string[] args)
{
List
List
}
}
Generics are mostly used with collections.
Wednesday, October 1, 2008
State Management Interview Questions
ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.
What is the lifespan for items stored in ViewState?
Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page). What does the "EnableViewState" property do? Why would I want it on or off?It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.
What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.