Sunday, February 17, 2008

C# Generics

What Are C# Generics?
Generics are one of the new features that Microsoft has proposed be added to the C# language. While not a part of the current C# specifications as defined by ECMA or ISO, they could be in the future.

Generics are used to help make the code in your software components much more reusable. They are a type of data structure that contains code that remains the same; however, the data type of the parameters can change with each use. Additionally, the usage within the data structure adapts to the different data type of the passed variables. In summary, a generic is a code template that can be applied to use the same code repeatedly. Each time the generic is used, it can be customized for different data types without needing to rewrite any of the internal code.

While generics would be new, the functionality that is provided by them can be obtained in C# today. This functionality is done by using type casts and polymorphism. With generics, however, you can avoid the messy and intensive conversions from reference types to native types. Additionally, you can create routines that are much more type-safe.

A generic is defined using a slightly different notation. The following is the basic code for a generic named Compare that can compare two items of the same type and return the larger or smaller value, depending on which method is called:

public class Compare
{
public ItemType Larger(ItemType data, ItemType data2)
{
// logic...
}

public ItemType Smaller(ItemType data, ItemType data2)
{
// logic...
}
}

This generic could be used with any data type, ranging from basic data types such as integers to complex classes and structures. When you use the generic, you identify what data type you are using with it. For example, to use an integer with the previous Compare generic, you would enter code similar to the following:

Compare compare = new Compare;
int MyInt = compare.Larger(3, 5);

You could use the type with other types as well. One thing to be aware of is that a declared generic, such Compare in the previous example, is strongly typed. This means that, if you pass a different data type than an integer to compare.Larger, the compiler will display an error. If you wanted to use a different data type, you would need to declare another instance of the generic:

Compare f_compare = new Compare;
float MyFloat = f_compare.Larger(1.23f, 4.32f);

Because you can use this with different types, you don't need to change the original generic code.

The example here is a simplification of what can be done with generics. You will find that, to truly create a generic type that can be used with any data type as a parameter, you will need to ensure that a number of requirements are met. One way to do this—the appropriate way—is with a constraint. A constraint is a class or interface that must be included as a part of the type used for the parameter. For example, in the previous Compare class, to make sure that any data type will work as a parameter when declaring the delegate, you can force the data types to have implemented the IComparable interface from the .NET Framework.

You can add a constraint by including it after the generic class declaration. You indicate a constraint by using the proposed new C# keyword where:

public class Compare
where ItemType : IComparable
{
public ItemType Larger(ItemType data, ItemType data2)
{
// logic...
}

public ItemType Smaller(ItemType data, ItemType data2)
{
// logic...
}
}

SharePoint Interview Questions - Must Read

1) What are the two base classes a WebPart you are going to use within SharePoint 2007 can inherit from?
There are two base classes that a WebPart which is going to be consumed by SharePoint can inherit from, either the SharePoint WebPart Base class or the ASP.NET 2.0 WebPart base class. When inheriting from the SharePoint WebPart Base class your derived WebPart class will inherit from Microsoft.SharePoint.WebPartPages.WebPart. When inheriting from the ASP.NET 2.0 WebPart base class your derived WebPart class will inherit from System.Web.UI.WebControls.WebParts.WebPart. It is considered good practice to use the ASP.NET WebPart base class since the old base class is meant for backwards compatibility with previous version of SharePoint, however there are four exception when it is better to leverage functionality from the SharePoint WebPart base class:
Cross page connections
Connections between Web Parts that are outside of a Web Part zone
Client-side connections (Web Part Page Services Component)
Data caching infrastructure
2) What are the differences between the two base classes and what are the inherit benefits of using one over another?
The difference is the Microsoft.SharePoint.WebPartPages.WebPart base class is meant for backward compatibility with previous versions of SharePoint. The benefit of using the SharePoint WebPart base class is it supported:
Cross page connections
Connections between Web Parts that are outside of a Web Part zone
Client-side connections (Web Part Page Services Component)
Data caching infrastructure
ASP.NET 2.0 WebParts are generally considered better to use because SharePoint is built upon the ASP.NET 2.0 web architecture. Inheriting from the ASP.NET 2.0 base class offers you features that inherit to ASP.NET 2.0, such as embedding resources as opposed to use ClassResources for deployment of said types.
3) What is the GAC?
The GAC stands for the global assembly cache. It is the machine wide code cache which will give custom binaries place into the full trust code group for SharePoint. Certain SharePoint assets, such as Feature Receivers need full trust to run correctly, and therefore are put into the GAC. You should always try to avoid deployment to the GAC as much as possible since it will possibly allow development code to do more than it was intended to do.
4) What is strong naming (signing) a WebPart assembly file mean?
Signing an assembly with a strong name (a.k.a strong naming) uses a cryptographic key pair that gives a unique identity to a component that is being built. This identity can then be referred throughout the rest of the environment. In order to install assemblies into the GAC, they must be strongly named. After signing, the binary will have a public key token identifier which can be use to register the component in various other places on the server.
5) What are safe controls, and what type of information, is placed in that element in a SharePoint web.config file?
When you deploy a WebPart to SharePoint, you must first make it as a safe control to use within SharePoint in the web.config file. Entries made in the safe controls element of SharePoint are encountered by the SharePointHandler object and will be loaded in the SharePoint environment properly, those not will not be loaded and will throw an error.
In the generic safe control entry (this is general, there could be more), there is generally the Assembly name, the namespace, the public key token numeric, the typename, and the safe declaration (whether it is safe or not). There are other optional elements.
6) What is the CreateChildControls() method? How can you use it to do something simple like displaying a Label control?
The CreateChildControls method in WebParts is used to notify the WebPart that there are children controls that should be output for rendering. Basically, it will add any child ASP.NET controls that are called instantiating each control with its relevant properties set, wire any relevant event handlers to the control, etc. Then the add method of the control class will add the control to the controls collection. In the relevant WebPart render method, the EnsureChildControls method can be called (or set to false if no child controls should be called) to ensure that the CreateChildControls method is run. When using CreateChildControls it implies that your WebPart contains a composition of child controls.
In order to create something like a label control in Create, you would create a new label control using the new keyword, set the various properties of the control like Visible=True and ForeColor = Color.Red, and then use Controls.Add(myLabelControl) to add the control to the controls collection. Then you can declare EnsureChildControls in the Render method of the WebPart.
7) What does the RenderContents method do in an ASP.NET 2.0 WebPart?
The render contents method will render the WebPart content to the writer, usually an HtmlTextWriter since WebParts will output to an HTML stream. RenderContents is used to tell how the controls that are going to be displayed in the WebPart should be rendered on the page.
*** Side Question: I got asked what the difference between CreateChildControls and the RenderContents method. The CreateChildControls method is used to add controls to the WebPart, and the RenderContents method is used to tell the page framework how to render the control into HTML to display on a page.
8) What is the WebPartManager sealed class? What is its purpose?
The WebPartManager sealed class is responsible for managing everything occurring on a WebPart page, such as the WebParts (controls), events, and misc. functionality that will occur in WebPartZones. For example, the WebPartManager is responsible for the functionality that is provided when you are working with moving a WebPart from WebPartZone to WebPartZone. It is known as the “the central class of the Web Part Control Set.”
*** Side Question: I got asked how many WebPartManager controls should be on a page. In order to have WebParts on a page there has to be just one WebPartManager control to manage all the WebParts on the page.
9) What is a SPSite and SPWeb object, and what is the difference between each of the objects?
The SPSite object represents a collection of sites (site collection [a top level sites and all its subsites]). The SPWeb object represents an instance SharePoint Web, and SPWeb object contains things like the actual content. A SPSite object contains the various subsites and the information regarding them.
10) How would you go about getting a reference to a site?
Select For Unformatted Code
C#:
1. oSPSite = new SPSite("http:/server");
2.
3. oSPWeb = oSPSite.OpenWeb();
11) What does a SPWebApplication object represent?
The SPWebApplication objects represents a SharePoint Web Application, which essentially is an IIS virtual server. Using the class you can instigate high level operations, such as getting all the features of an entire Web Application instance, or doing high level creation operations like creating new Web Applications through code.
12) Would you use SPWebApplication to get information like the SMTP address of the SharePoint site?
Yes, since this is a Web Application level setting. You would iterate through each SPWebApplication in the SPWebApplication collection, and then use the appropriate property calls (OutboundMailServiceInstance) in order to return settings regarding the mail service such as the SMTP address.
Side Question: I got asked if there are other ways to send emails from SharePoint. The answer is yes, there is. You can use the SendMail method from the SPutility class to send simple emails, however it is not as robust as using the System.Net.Mail functionality since it doesn’t allow things like setting priorities on the email.
13) How do you connect (reference) to a SharePoint list, and how do you insert a new List Item?
Select For Unformatted Code
C#:
1. using(SPSite mySite = new SPSite("yourserver"))
2. {
3. using(SPWeb myWeb = mySite.OpenWeb())
4. {
5. SPList interviewList = myWeb.Lists["listtoinsert"];
6. SPListItem newItem = interviewList.Items.Add();
7.
8. newItem["interview"] = "interview";
9. newItem.Update();
10. }
11. }
14) How would you loop using SPList through all SharePont List items, assuming you know the name (in a string value) of the list you want to iterate through, and already have all the site code written?
Select For Unformatted Code
C#:
1. SPList interviewList = myWeb.Lists["listtoiterate"];
2. foreach (SPListItem interview in interviewList)
3. {
4. // Do Something
5. }
15) How do you return SharePoint List items using SharePoint web services?
In order to retrieve list items from a SharePoint list through Web Services, you should use the lists.asmx web service by establishing a web reference in Visual Studio. The lists.asmx exposes the GetListItems method, which will allow the return of the full content of the list in an XML node. It will take parameters like the GUID of the name of the list you are querying against, the GUID of the view you are going to query, etc.
Side Question: I got asked how I built queries with the lists.asmx web service. In order to build queries with this service, one of the parameters that the GetListItems method exposes is the option to build a CAML query. There are other ways to do this as well, but that was how I answered it.
16) When retrieving List items using SharePoint Web Services, how do you specify explicit credentials to be passed to access the list items?
In order to specify explicit credentials with a Web Service, you generally instantiate the web service, and then using the credentials properties of the Web Service object you use the System.Net.NetworkCredential class to specify the username, password, and domain that you wish to pass when making the web service call and operations.
*** Side Question: I got asked when you should state the credentials in code. You must state the credentials you are going to pass to the web service before you call any of the methods of the web service, otherwise the call will fail.
17) What is CAML, and why would you use it?
CAML stands for Collaborative Application Markup Language. CAML is an XML based language which provides data constructs that build up the SharePoint fields, view, and is used for table definition during site provisioning. CAML is responsible for rending data and the resulting HTML that is output to the user in SharePoint. CAML can be used for a variety of circumstances, overall is used to query, build and customize SharePoint based sites. A general use would be building a CAML query in a SharePoint WebPart in order to retrieve values from a SharePoint list.
18) What is impersonation, and when would you use impersonation?
Impersonation can basically provide the functionality of executing something in the context of a different identity, for example assigning an account to users with anonymous access. You would use impersonation in order to access resources on behalf of the user with a different account, that normally, that wouldn’t be able to access or execute something.
19) What is the IDesignTimeHtmlProvider interface, and when can you use it in WebParts?
The IDesignTimeHtmlProvider interface uses the function GetDesignTimeHtml() which can contain your relevant render methods. It was helpful to use in 2003 since it allowed your WebPart to have a preview while a page was edited in FrontPage with the Webpart on it, because the GetDesignTimeHtml() method contains the HTML for the designer to render.
20) What are WebPart properties, and what are some of the attributes you see when declaring WebPart properties in code?
WebPart properties are just like ASP.NET control properties, they are used to interact with and specify attributes that should be applied to a WebPart by a user. Some of the attributes you see with ASP.NET 2.0 properties are WebDescription, WebDisplayName, Category, Personalizable, and WebBrowsable. Although most of these properties come from the System.Web.UI.WebControls.WebParts class, ones like Category come out of System.ComponentModel namespace.
21) Why are properties important in WebPart development, and how have you exploited them in past development projects? What must each custom property have?
Properties are important because WebParts allow levels of personalization for each user. WebPart properties make it possible for a user to interact, adjust, and increase overall experience value with the programmatic assets that you develop without having the need to use an external editor or right any code. A very simple example of exploiting a property would be something like allowing the user to change the text on the WebPart design interface so that they can display whatever string of text they desire.
Each custom property that you have must have the appropriate get and set accessor methods.
22) What are ClassResources? How do you reference and deploy resources with an ASP.NET 2.0 WebPart?
ClassResources are used when inheriting from the SharePoint.WebPart.WebPartPages.WebPart base class, and are defined in the SharePoint solution file as things that should be stored in the wpresources directory on the server. It is a helpful directory to use in order to deploy custom images. In ASP.NET 2.0, typically things such as images are referenced by embedding them as resources within an assembly. The good part about ClassResources is they can help to eliminate recompiles to change small interface adjustments or alterations to external JavaScript files.
23) What is a SharePoint Solution File? How does it differ from WebPart .cab files in legacy development? What does it contain?
A SharePoint solution file is essentially a .cabinet file with all a developers ustom componets suffixed with a .wsp extension that aids in deployment. The big difference with SharePoint solution files is is that a solution:
allows deployment to all WFE’s in a farm
is highly manageable from the interface allowing deployment, retraction, and versioning
Can package all types of assets like site definitions, feature definitions (and associated components), Webparts, etc.
Can provide Code Access Security provisioning to avoid GAC deployments
Just to name a few things…
24) What is a .ddf file and what does it have to do with SharePoint Solution creation?
A .ddf file is a data directive file and is used when building the SharePoint solution bundle specifying the source files and their destination locations. The important thing for someone to understand is that the .ddf file will be passed as a parameter to the MAKECAB utility to orchestrate construction of the SharePoint solution fiel.
25) What file does a SharePoint solution package use to orchestrate (describe) its packaged contents?
The solution Manifest.XML file.
26) What deployment mechanism can you use to instigate Code Access Security attributes for your WebParts?
SharePoint solution files can add in order to handle code access security deployment issues. This is done in the element in the SharePoint solution manifest.XML, which makes it easier to get assemblies the appropriate permissions in order to operate in the bin directory of the web application.
27) What is a SharePoint Feature? What files are used to define a feature?
A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances, such as at the farm, site collection, web, etc. Features have their own receiver architecture, which allow you to trap events such as when a feature is installing, uninstalling, activated, or deactivated. They are helpful because they allow ease of upgrades and versioning.
The two files that are used to define a feature are the feature.xml and manifest file. The feature XML file defines the actual feature and will make SharePoint aware of the installed feature. The manifest file contains details about the feature such as functionality.
Side Question: I got asked how the introduction of features has changed the concept of site definitions. SharePoint features are important when understanding the architecture of site definitions, since the ONET.XML file has been vastly truncated since it has several feature stapled on it.
28) What types of SharePoint assets can be deployed with a SharePoint feature?
Features can do a lot. For example, you could deploy
Simple site customizations
Custom site navigation
WebParts
pages
list types
list instances
event handlers
workflows
custom actions
just to name a few….
29) What are event receivers?
Event receivers are classes that inherit from the SpItemEventReciever or SPListEventReciever base class (both of which derive out of the abstract base class SPEventRecieverBase), and provide the option of responding to events as they occur within SharePoint, such as adding an item or deleting an item.
30) When would you use an event receiver?
Since event receivers respond to events, you could use a receiver for something as simple as canceling an action, such as deleting a document library by using the Cancel property. This would essentially prevent users from deleting any documents if you wanted to maintain retention of stored data.
31) What base class do event receivers inherit from?
Event receivers either inherit from the SPListEventReciever base class or the SPItemEventReciever base class, both which derive from the abstract base class SPEventReceiverBase.
32) If I wanted to not allow people to delete documents from a document library, how would I go about it?
You would on the ItemDeleting event set: properties.Cancel= true.
33) What is the difference between an asynchronous and synchronous event receivers?
An asynchronous event occurs after an action has taken place, and a synchronous event occurs before an action has take place. For example, an asynchronous event is ItemAdded, and its sister synchronous event is ItemAdding.
34) How could you append a string to the title of a site when it is provisioned?
In the OnActivated event:
Select For Unformatted Code
C#:
1. SPWeb site = siteCollection.RootWeb;
2. site.Title += "interview";
3. site.Update();
35) Can an event receiver be deployed through a SharePoint feature?
Yes.
36) What is a content type?
A content type is an information blueprint basically that can be re-used throughout a SharePoint environment for defining things like metadata and associated behaviors. It is basically an extension of a SharePoint list, however makes it portable for use throughout an instance regardless of where the instantiation occurs, ergo has location independence. Multiple content types can exist in one document library assuming that the appropriate document library settings are enabled. The content type will contain things like the metadata, listform pages, workflows, templates (if a document content type), and associated custom written functionality.
37) Can a content type have receivers associated with it?
Yes, a content type can have an event receiver associated with it, either inheriting from the SPListEventReciever base class for list level events, or inheriting from the SPItemEventReciever base class. Whenever the content type is instantiated, it will be subject to the event receivers that are associated with it.
38) What two files are typically (this is kept generally) included when developing a content type, and what is the purpose of each?
There is generally the main content type file that holds things like the content type ID, name, group, description, and version. There is also the ContentType.Fields file which contains the fields to include in the content type that has the ID, Type, Name, DisplayName, StaticName, Hidden, Required, and Sealed elements. They are related by the FieldRefs element in the main content type file.
39) What is an ancestral type and what does it have to do with content types?
An ancestral type is the base type that the content type is deriving from, such as Document (0x0101). The ancestral type will define the metadata fields that are included with the custom content type.
40) Can a list definition be derived from a custom content type?
Yes, a list definition can derive from a content type which can be seen in the schema.XML of the list definition in the element.
41) When creating a list definition, how can you create an instance of the list?
You can create a new instance of a list by creating an instance.XML file.
42) What is a Field Control?
Field controls are simple ASP.NET 2.0 server controls that provide the basic field functionality of SharePoint. They provide basic general functionality such as displaying or editing list data as it appears on SharePoint list pages.
43) What base class do custom Field Controls inherit from?
This varies. Generally, custom field controls inherit from the Microsoft.SharePoint.WebControls.BaseFieldControl namespace, but you can inherit from the default field controls.
44) What is a SharePoint site definition? What is ghosted (uncustomized) and unghosted (customized)?
SharePoint site definitions are the core set of functionality from which SharePoint site are built from, building from the SiteTemplates directory in the SharePoint 12 hive. Site definitions allow several sites to inherit from a core set of files on the file system, although appear to have unique pages, thereby increasing performance and allowing changes that happen to a site propagate to all sites that inherit from a site definition. Ghosted means that when SharePoint creates a new site it will reference the files in the related site definition upon site provisioning. Unghosted means that the site has been edited with an external editor, and therefore the customizations are instead stored in the database, breaking the inheritance of those files from the file system.
45) How does one deploy new SharePoint site definitions so that they are made aware to the SharePoint system?
The best way to deploy site definitions in the SharePoint 2007 framework is to use a SharePoint solution file, so that the new site definition is automatically populated to all WFE’s in the SharePoint farm.

Saturday, February 16, 2008

SharePoint Interview Qestions

Sharepoint Portal Interview Questions what is SharePoint?
Portal Collaboration Software.
what is the difference between SharePoint Portal Server and Windows SharePoint Services?
SharePoint Portal Server is the global portal offering features like global navigation and searching.
Windows SharePoint Services is more content management based with document libraries and
lists. You apply information to certain areas within your portal from Windows SharePoint
Services or directly to portal areas.
what is a document library?
A document library is where you upload your core documents. They consist of a row and column
view with links to the documents. When the document is updated so is the link on your site. You
can also track metadata on your documents. Metadata would consist of document properties.
what is a meeting workspace?
A meeting workspace is a place to store information, attendees, and tasks related to a specific
meeting.
what is a document workspace?
Document workspaces consist of information surrounding a single or multiple documents.
what is a web part?
Web parts consist of xml queries to full SharePoint lists or document libraries. You can also
develop your own web parts and web part pages.
what is the difference between a document library and a form library?
Document libraries consist of your core documents. An example would be a word document,
excel, powerpoint, visio, pdf, etc… Form libraries consist of XML forms.
what is a web part zone?
Web part zones are what your web parts reside in and help categorize your web parts when
designing a page.
how is security managed in SharePoint?
Security can be handled at the machine, domain, or sharepoint level.
how are web parts developed?
Web parts are developed in Visual Studio .Net. VS.Net offers many web part and page templates
and can also be downloaded from the Microsoft site.
what is a site definition?
It’s a methods for providing prepackaged site and list content.
what is a template?
A template is a pre-defined set of functions or settings that can be used over time. There are many
templates within SharePoint, Site Templates, Document Templates, Document Library and List
Templates.
vabnix.page.tl
how do you install web parts?
Web Parts should be distributed as a .CAB (cabinet) file using the MSI Installer.
what is CAML?
CAML stands for Collaborative Application Markup Language and is an XML-based language
that is used in Microsoft Windows SharePoint Services to define sites and lists, including, for
example, fields, views, or forms, but CAML is also used to define tables in the Windows
SharePoint Services database during site provisioning.
what is a DWP?
The file extension of a web part.
what is the GAC?
Global Assembly Cache folder on the server hosting SharePoint. You place your assemblies there
for web parts and services.
what are the differences between web part page gallery, site gallery, virtual server gallery
and online gallery?
Web Part Page Gallery is the default gallery that comes installed with SharePoint. Site Gallery is
specific to one site. Virtual Server gallery is specific to that virtual server and online gallery are
downloadable web parts from Microsoft.
what is the difference between a site and a web?
The pages in a Web site generally cover one or more topics and are interconnected through
hyperlinks. Most Web sites have a home page as their starting point. While a Web is simply a
blank site with SharePoint functionality built in; meaning you have to create the site from the
ground up.
What is Microsoft Windows SharePoint Services? How is it related to Microsoft Office
SharePoint Server 2007?
Windows SharePoint Services is the solution that enables you to create Web sites for information
sharing and document collaboration. Windows SharePoint Services — a key piece of the
information worker infrastructure delivered in Microsoft Windows Server 2003 — provides
additional functionality to the Microsoft Office system and other desktop applications, and it
serves as a platform for application development.
Office SharePoint Server 2007 builds on top of Windows SharePoint Services 3.0 to provide
additional capabilities including collaboration, portal, search, enterprise content management,
business process and forms, and business intelligence.
What is Microsoft SharePoint Portal Server?
SharePoint Portal Server is a portal server that connects people, teams, and knowledge across
business processes. SharePoint Portal Server integrates information from various systems into one
secure solution through single sign-on and enterprise application integration capabilities. It
provides flexible deployment and management tools, and facilitates end-to-end collaboration
through data aggregation, organization, and searching. SharePoint Portal Server also enables users
to quickly find relevant information through customization and personalization of portal content
and layout as well as through audience targeting.
What is Microsoft Windows Services?
Microsoft Windows Services is the engine that allows administrators to create Web sites for
information sharing and document collaboration. Windows SharePoint Services provides
additional functionality to the Microsoft Office System and other desktop applications, as well as
serving as a plat form for application development. SharePoint sites provide communities for team

vabnix.page.tl
collaboration, enabling users to work together on documents, tasks, and projects. The environment
for easy and flexible deployment, administration, and application development.
What is the relationship between Microsoft SharePoint Portal Server and Microsoft
Windows Services?
Microsoft SharePoint Products and Technologies (including SharePoint Portal Server and
Windows SharePoint Services) deliver highly scalable collaboration solutions with flexible
deployment and management tools. Windows SharePoint Services provides sites for team
collaboration, while Share Point Portal Server connects these sites, people, and business processes
—facilitating knowledge sharing and smart organizations. SharePoint Portal Server also extends
the capabilities of Windows SharePoint Services by providing organizational and management
tools for SharePoint sites, and by enabling teams to publish information to the entire organization.
Who is Office SharePoint Server 2007 designed for?
Office SharePoint Server 2007 can be used by information workers, IT administrators, and
application developers.
is designed
What are the main benefits of Office SharePoint Server 2007?
Office SharePoint Server 2007 provides a single integrated platform to manage intranet, extranet,
and Internet applications across the enterprise.
* Business users gain greater control over the storage, security, distribution, and management of
their electronic content, with tools that are easy to use and tightly integrated into familiar,
everyday applications.
* Organizations can accelerate shared business processes with customers and partners across
organizational boundaries using InfoPath Forms Services–driven solutions.
* Information workers can find information and people efficiently and easily through the
facilitated information-sharing functionality and simplified content publishing. In addition, access
to back-end data is achieved easily through a browser, and views into this data can be
personalized.
* Administrators have powerful tools at their fingertips that ease deployment, management, and
system administration, so they can spend more time on strategic tasks.
* Developers have a rich platform to build a new class of applications, called Office Business
Applications, that combine powerful developer functionality with the flexibility and ease of
deployment of Office SharePoint Server 2007. Through the use of out-of-the-box application
services, developers can build richer applications with less code.
What is the difference between Microsoft Office SharePoint Server 2007 for Internet sites
and Microsoft Office SharePoint Server 2007?
Microsoft Office SharePoint Server 2007 for Internet sites and Microsoft Office SharePoint Server
2007 have identical feature functionality. While the feature functionality is similar, the usage
rights are different.
If you are creating an Internet, or Extranet, facing website, it is recommended that you use
Microsoft Office SharePoint Server 2007 for Internet sites which does not require the purchase
client access licenses. Websites hosted using an “Internet sites” edition can only be used for
Internet facing websites and all content, information, and applications must be accessible to nonemployees.
Websites hosted using an “Internet sites” edition cannot be accessed by employees
creating, sharing, or collaborating on content which is solely for internal use only, such as an
Intranet Portal scenario. See the previous section on licensing for more information on the usage
scenarios.
What suites of the 2007 Microsoft Office system work with Office SharePoint Server 2007?
Office Outlook 2007 provides bidirectional offline synchronization with SharePoint document
libraries, discussion groups, contacts, calendars, and tasks.

vabnix.page.tl
Microsoft Office Groove 2007, included as part of Microsoft Office Enterprise 2007, will enable
bidirectional offline synchronization with SharePoint document libraries.
Features such as the document panel and the ability to publish to Excel Services will only be
enabled when using Microsoft Office Professional Plus 2007or Office Enterprise 2007.
Excel Services will only work with documents saved in the new Office Excel 2007 file format
(XLSX).
How do I invite users to join a Windows SharePoint Services Site? Is the site secure?
SharePoint-based Web sites can be password-protected to restrict access to registered users, who
are invited to join via e-mail. In addition, the site administrator can restrict certain members' roles
by assigning different permission levels to view post and edit.
Can I post any kind of document?
You can post documents in many formats, including .pdf, .htm and .doc. In addition, if you are
using Microsoft Office XP, you can save documents directly to your Windows SharePoint
Services site.
Can I download information directly from a SharePoint site to a personal digital assistant
(PDA)?
No you cannot. However, you can exchange contact information lists with Microsoft Outlook.
How long does it take to set up the initial team Web site?
It only takes a few minutes to create a complete Web site. Preformatted forms let you and your
team members contribute to the site by filling out lists. Standard forms include announcements,
events, contacts, tasks, surveys, discussions and links.
Can I create custom templates?
Yes you can. You can have templates for business plans, doctor's office, lawyer's office etc.
How can I make my site public?
By default, all sites are created private.If you want your site to be a public Web site, enable
anonymous access for the entire site. Then you can give out your URL to anybody in your
business card, e-mail or any other marketing material. The URL for your Web site will be:
http:// yoursitename.wss.bcentral.com
Hence, please take special care to name your site.
These Web sites are ideal for information and knowledge intensive sites and/or sites where you
need to have shared Web workspace.
Remember: Under each parent Web site, you can create up to 10 sub-sites each with unique
permissions, settings and security rights
.
How do the sub sites work?
You can create a sub site for various categories. For example:
* Departments - finance, marketing, IT
* Products - electrical, mechanical, hydraulics
* Projects - Trey Research, Department of Transportation, FDA
* Team - Retention team, BPR team
* Clients - new clients, old clients
* Suppliers - Supplier 1, Supplier 2, Supplier 3
* Customers - Customer A, Customer B, Customer C
* Real estate - property A, property B
The URLs for each will be, for example:
* http://yoursitename.wss.bcentral.com/finance
* http://yoursitename.wss.bcentral.com/marketing
You can keep track of permissions for each team separately so that access is restricted while

vabnix.page.tl
maintaining global access to the parent site.
How do I make my site non-restricted?
If you want your site to have anonymous access enabled (i.e., you want to treat it like any site on
the Internet that does not ask you to provide a user name and password to see the content of the
site), follow these simple steps:
# Login as an administrator
# Click on site settings
# Click on Go to Site Administration
# Click on Manage anonymous access
# Choose one of the three conditions on what Anonymous users can access:
** Entire Web site
** Lists and libraries
** Nothing
Default condition is nothing; your site has restricted access. The default conditions allow you to
create a secure site for your Web site.
Can I get domain name for my Web site?
Unfortunately, no. At this point, we don't offer domain names for SharePoint sites. But very soon
we will be making this available for all our SharePoint site customers. Please keep checking this
page for further update on this. Meanwhile, we suggest you go ahead and set up your site and
create content for it.
What are picture libraries?
Picture libraries allow you to access a photo album and view it as a slide show or thumbnails or a
film strip. You can have separate folder for each event, category, etc
What are the advantages of a hosted SharePoint vs. one that is on an in-house server?
* No hardware investment, i.e. lower costs
* No software to download - ready to start from the word go
* No IT resources - Anyone who has used a Web program like Hotmail can use it
* Faster deployment
Can I ask users outside of my organization to participate in my Windows SharePoint
Services site?
Yes. You can manage this process using the Administration Site Settings. Simply add users via
their e-mail alias and assign permissions such as Reader or Contributor.
Are there any IT requirements or downloads required to set up my SharePoint site?
No. You do not need to download any code or plan for any IT support. Simply complete the online
signup process and provide us your current and correct email address. Once you have
successfully signed up and your site has been provisioned, we will send a confirmation to the
email address you provided.
I am located outside of the United States. Are there any restrictions or requirements for
accessing the Windows SharePoint Services?
No. There are no system or bandwidth limitations for international trial users. Additionally
language packs have been installed which allow users to set up sub-webs in languages other than
English. These include: Arabic, Danish, Dutch, Finnish, French, German, Hebrew, Italian,
Japanese, Polish, Portuguese (Brazilian), Spanish and Swedish.
Are there any browser recommendations?
Yes. Microsoft recommends using the following browsers for viewing and editing Windows
SharePoint Services sites: Microsoft Internet Explorer 5.01 with Service Pack 2, Microsoft
Internet Explorer 5.5 with Service Pack 2, Internet Explorer 6, Netscape Navigator 6.2 or later.

vabnix.page.tl
What security levels are assigned to users?
Security levels are assigned by the administrator who is adding the user. There are four levels by
default and additional levels can be composed as necessary.
* Reader - Has read-only access to the Web site.
* Contributor - Can add content to existing document libraries and lists.
* Web Designer - Can create lists and document libraries and customize pages in the Web site.
* Administrator - Has full control of the Web site.
How secure are Windows SharePoint Services sites hosted by Microsoft?
Microsoft Windows SharePoint Services Technical security measures provide firewall protection,
intrusion detection, and web-publishing rules. The Microsoft operation center team tests and
deploys software updates in order to maintain the highest level of security and software reliability.
Software hot-fixes and service packs are tested and deployed based on their priority and level of
risk. Security related hot-fixes are rapidly deployed into the environment to address current
threats. A comprehensive software validation activity ensures software stability through regression
testing prior to deployment.
What is the difference between an Internet and an intranet site?
An internet site is a normal site that anyone on the internet can access (e.g., www.msn.com, www.
microsoft.com, etc.). You can set up a site for your company that can be accessed by anyone
without any user name and password.
An intranet (or internal network), though hosted on the Web, can only be accessed by people who
are members of the network. They need to have a login and password that was assigned to them
when they were added to the site by the site administrator.
What is a workspace?
A site or workspace is when you want a new place for collaborating on Web pages, lists and
document libraries. For example, you might create a site to manage a new team or project,
collaborate on a document or prepare for a meeting.
What are the various kinds of roles the users can have?
A user can be assigned one of the following roles
* Reader - Has read-only access to the Web site.
* Contributor - Can add content to existing document libraries and lists.
* Web Designer - Can create lists and document libraries and customize pages in the Web site.
* Administrator - Has full control of the Web site.
Can more than one person use the same login?
If the users sharing that login will have the same permissions and there is no fear of them sharing a
password, then yes. Otherwise, this is discouraged.
How customizable is the user-to-user access?
User permissions apply to an entire Web, not to documents themselves. However, you can have
additional sub webs that can optionally have their own permissions. Each user can be given any of
four default roles. Additional roles can be defined by the administrator.
Can each user have access to their own calendar?
Yes there are two ways to do this,
* by creating a calendar for each user, or
* by creating a calendar with a view for each user
How many files can I upload?
There is no restriction in place except that any storage consumed beyond that provided by the base
offering may have an additional monthly charge associated with them.

vabnix.page.tl
What types of files can I upload / post to the site?
The only files restricted are those ending with the following extensions: .asa, .asp, .ida, .idc, .idq.
Microsoft reserves the right to add additional file types to this listing at any time. Also, no content
that violates the terms of service may be uploaded or posted to the site.
Can SharePoint be linked to an external data source?
SharePoint data can be opened with Access and Excel as an external data source. Thus, SharePoint
can be referenced as an external data source. SharePoint itself cannot reference an external data
source.
Can SharePoint be linked to a SQL database?
This is possible via a custom application, but it not natively supported by SharePoint or SQL
Server.
Can I customize my Windows SharePoint Services site?
YES! Windows SharePoint Services makes updating sites and their content from the browser
easier then ever.
SharePoint includes tools that let you create custom lists, calendars, page views, etc. You can
apply a theme; add List, Survey and Document Library Web Parts to a page; create personal
views; change logos; connect Web Parts and more.
To fully customize your site, you can use Microsoft FrontPage 2003. Specifically, you can use
FrontPage themes and shared borders, and also use FrontPage to create photo galleries and top ten
lists, utilize standard usage reports, and integrate automatic Web content.
Will Microsoft Office SharePoint Server 2007 run on a 64-bit version of Microsoft
Windows?
Windows SharePoint Services 3.0, Office SharePoint Server 2007, Office Forms Server 2007, and
Office SharePoint Server 2007 for Search will support 64-bit versions of Windows Server 2003.
How Office SharePoint Server 2007 can help you?
Office SharePoint Server 2007 can help us:
Manage content and streamline processes. Comprehensively manage and control unstructured
content like Microsoft Office documents, Web pages, Portable Document Format file (PDF) files,
and e-mail messages. Streamline business processes that are a drain on organizational
productivity.
Improve business insight. Monitor your business, enable better-informed decisions, and respond
proactively to business events.
Find and share information more simply. Find information and expertise wherever they are
located. Share knowledge and simplify working with others within and across organizational
boundaries.
Empower IT to make a strategic impact. Increase responsiveness of IT to business needs and
reduce the number of platforms that have to be maintained by supporting all the intranet, extranet,
and Web applications across the enterprise with one integrated platform.
Office SharePoint Server 2007 capabilities can help improve organizational effectiveness by
connecting people, processes, and information.
Office SharePoint Server 2007 provides these capabilities in an integrated server offering, so your
organization doesn't have to integrate fragmented technology solutions itself.
What are the features that the portal components of Office SharePoint Server 2007 include?
The portal components of Office SharePoint Server 2007 include features that are especially
useful for designing, deploying, and managing enterprise intranet portals, corporate Internet Web
sites, and divisional portal sites. The portal components make it easier to connect to people within
the organization who have the right skills, knowledge, and project experience.

vabnix.page.tl
What are the advanced features of MOSS 2007?
* User Interface (UI) and navigation enhancements
* Document management enhancements
* The new Workflow engine
* Office 2007 Integration
* New Web Parts
* New Site-type templates
* Enhancements to List technology
* Web Content Management
* Business Data Catalog
* Search enhancements
* Report Center
* Records Management
* Business Intelligence and Excel Server
* Forms Server and InfoPath
* The “Features” feature
* Alternate authentication providers and Forms-based authentication
What are the features of the new Content management in Office SharePoint 2007?
The new and enhanced content management features in Office SharePoint Server 2007 fall within
three areas:
* Document management
* Records management
* Web content management
Office SharePoint Server 2007 builds on the core document management functionality provided
by Windows SharePoint Services 3.0, including check in and check out, versioning, metadata, and
role-based granular access controls. Organizations can use this functionality to deliver enhanced
authoring, business document processing, Web content management and publishing, records
management, policy management, and support for multilingual publishing.
Does a SharePoint Web site include search functionality?
Yes. SharePoint Team Services provides a powerful text-based search feature that helps you find
documents and information fast.
Write the features of the search component of Office SharePoint Server 2007?
The search component of Office SharePoint Server 2007 has been significantly enhanced by this
release of SharePoint Products and Technologies. New features provide:
* A consistent and familiar search experience.
* Increased relevance of search results.
* New functions to search for people and expertise.
* Ability to index and search data in line-of-business applications and
* Improved manageability and extensibility.
What are the benefits of Microsoft Office SharePoint Server 2007?
* Provide a simple, familiar, and consistent user experience.
* Boost employee productivity by simplifying everyday business activities.
* Help meet regulatory requirements through comprehensive control over content.
* Effectively manage and repurpose content to gain increased business value.
* Simplify organization-wide access to both structured and unstructured information across
disparate systems.
* Connect people with information and expertise.
* Accelerate shared business processes across organizational boundaries.
* Share business data without divulging sensitive information.

vabnix.page.tl
* Enable people to make better-informed decisions by presenting business-critical information in
one central location.
* Provide a single, integrated platform to manage intranet, extranet, and Internet applications
across the enterprise.
Will SharePoint Portal Server and Team Services ever merge?
The products will come together because they are both developed by the Office team.
What does partial trust mean the Web Part developer?
If an assembly is installed into the BIN directory, the code must be ensured that provides error
handling in the event that required permissions are not available. Otherwise, unhandled security
exceptions may cause the Web Part to fail and may affect page rendering on the page where the
Web Part appears.
How can I raise the trust level for assemblies installed in the BIN directory?
Windows SharePoint Services can use any of the following three options from ASP.NET and the
CLR to provide assemblies installed in the BIN directory with sufficient permissions. The
following table outlines the implications and requirements for each option.
Option Pros Cons Increase the trust level for the entire virtual server. For more information, see
"Setting the trust level for a virtual server" Easy to implement. In a development environment,
increasing the trust level allows you to test an assembly with increased permissions while allowing
you to recompile assemblies directly into the BIN directory without resetting IIS. This option is
least secure. This option affects all assemblies used by the virtual server.
There is no guarantee the destination server has the required trust level. Therefore, Web Parts may
not work once installed on the destination server.
Create a custom policy file for your assemblies. For more information, see "How do I create a
custom policy file?" Recommended approach.
This option is most secure.
An assembly can operate with a unique policy that meets the minimum permission requirements
for the assembly.
By creating a custom security policy, you can ensure the destination server can run your Web
Parts.
Requires the most configuration of all three options.
Install your assemblies in the GAC
Easy to implement.
This grants Full trust to your assembly without affecting the trust level of assemblies installed in
the BIN directory.
This option is less secure.
Assemblies installed in the GAC are available to all virtual servers and applications on a server
running Windows SharePoint Services. This could represent a potential security risk as it
potentially grants a higher level of permission to your assembly across a larger scope than
necessary
In a development environment, you must reset IIS every time you recompile assemblies.
Licensing issues may arise due to the global availability of your assembly.
Does SharePoint work with NFS?
Yes and no. It can crawl documents on an NFS volume, but the sharepoint database or logs cannot
be stored there.
How is SharePoint Portal Server different from the Site Server?
Site Server has search capabilities but these are more advanced using SharePoint. SPS uses digital
dashboard technology which provides a nice interface for creating web parts and showing them on
dashboards (pages). SS doesn't have anything as advanced as that. The biggest difference would
be SPS document management features which also integrate with web folders and MS Office.

vabnix.page.tl
What would you like to see in the next version of SharePoint?
A few suggestions:
# SPS and STS on same machine
# Tree view of Categories and Folders
# General Discussion Web Part
# Personalization of Dashboards
# Role Customization
# Email to say WHY a document has been rejected for Approval
# More ways to customize the interface
# Backup and restore an individual Workspaces
# Filter for Visio
# Better way to track activity on SPS
Why Sharepoint is not a viable solution for enterprise wide deployments?
Document management does not scale beyond a single server, but scales great within a single
server. For example, a quad Xeon machine with 4GB of RAM works great for a document
management server that has about 900,000 - 1,000,000 document, but if you need to store
50,000,000 document and want to have them all in one single workspace then it does not scale at
all. If you need a scenario like this, you need to plan your deployment right and it should scale for
you, it just does not right out of the box.
If you are using your server as a portal and search server most for the most part it scales great.
You can have many different servers crawl content sources and have separate servers searching
and serving the content.
If you have <>
50,000 users, SPS should scale just fine for your needs with the proper planning.
What are the actual advantages of SharePoint Portal Services (SPS) over SharePoint Team
Services (STS)?
SharePoint Portal Services (SPS) has MUCH better document management. It has check-in,
check-out, versioning, approval, publishing, subscriptions, categories, etc. STS does not have
these features, or they are very scaled back. SharePoint team Services (SPS) has a better search
engine, and can crawl multiple content sources. STS cannot. STS is easier to manage and much
better for a team environment where there is not much Document Management going on. SPS is
better for an organization, or where Document Management is crucial.
How Does SharePoint work?
The browser sends a DAV packet to IIS asking to perform a document check in. PKMDASL.DLL,
an ISAPI DLL, parses the packet and sees that it has the proprietary INVOKE command. Because
of the existence of this command, the packet is passed off to msdmserv.exe, who in turn processes
the packet and uses EXOLEDB to access the WSS, perform the operation and send the results
back to the user in the form of XML.

Transaction in .Net

What is a Transaction?
Frequently in a database application you come across a situation where you need to execute two or more SQL commands in such a way that if any one of the statements fails, then no other statement will be able to change the database. The classic example of this is transferring money from a bank account into another bank account:

UPDATE Accounts SET Balance = Balance – 10 WHERE Customer = 1;
UPDATE Accounts SET Balance = Balance + 10 WHERE Customer = 2;

If the first SQL statement was to execute and the second SQL statement was to fail, then ten dollars would be removed from the first customer’s account but will never be added to the second customer’s account. This would, naturally, be bad – ten dollars has just disappeared entirely.

One way to deal with this would be to handle the situation in your database access code. You could do this by catching System.Data.SqlClient.SqlException when you do your database access. The situation is not as easy as it first appears, however. The SQL statements could have failed in a number of places:

Before the first SQL statement is executed.
After the first SQL statement is executed.
After the second SQL statement is executed.
This means that you have to determine what the balances of both the accounts were before the transfer and, after the exception was thrown, determine which account’s current balance doesn’t match the starting balance, and execute an UPDATE statement. This can, potentially, be a lot of code – especially if your example is non-trivial.

The situation is made even worse by the fact that SQL Server is a multi-user environment. At any given point of time, other users could be accessing the Accounts table – and if they access that table between your statement failing and your corrections to the table, they could very well access invalid data. This would be extraordinarily bad, and could lead to immensely hard to find bugs in your code. (bugs relating to data synchronization across several threads or processes are so difficult to find, that they have their own name: ‘Heisenbugs’)

Modern database theory postulates that in a perfect transaction world, a database would have a series of properties known as ACID. These properties are:

Atomic – All statements in a group must execute, or no statement in a group must execute.
Consistent – This follows naturally from atomic – a group of SQL statements must take the database from a known starting state to a known ending state. If the statements execute, the database must be at the known ending state. If the statements fail, the database must be at the known starting state.
Isolated – A group of statements must execute independently from any other statement groups being executed at the same time. If this wasn’t the case, it would be impossible for statement groups to be consistent – the known ending state could be altered by a code you have no control over or knowledge of. This is one of those concepts that are great in theory, but total isolation has important performance implications in the real world. More on how SQL Server implements this is explained later.
Durable – Once the group of SQL statements execute, the results need to be stored in a permanent media – if the database crashes right after a group of SQL statements execute, it should be possible to restore the database state to the point after the last transaction committed.
In SQL Server, ACID-ness is provided by the concept of transactions. Simply put, a transaction is a way to group SQL statements together so that, when executed, the transaction obeys the ACID principles. A transaction is enabled on a single connection to the database (over the lifetime of a SqlConnection object, in .NET parlance) and will apply to all commands executed over that connection until the transaction ends. Once you have a transaction, there are two things you can do with it. You can either commit the transaction to the database at the end of the transaction, or you can abandon the transaction and rollback the changes made in the transaction.

In terms of Transact-SQL, there are three importance commands to manage a transaction. BEGIN TRANSACTION will begin a transaction, COMMIT TRANSACTION will commit the transaction to the database, and ROLLBACK TRANSACTION will roll the transaction back. These statements can actually be a little more complicated – feel free to refer to the MSDN documentation regarding these statements.

.NET Transactions
Within .NET, transactions are managed with the System.Data.SqlClient.SqlTransaction class. Again, a transaction exists over a SqlConnection object – and thus all the SqlCommand objects you create using that connection. Let's look at a quick example:

Collapsepublic class TransactionDemo
{
public TransactionDemo()
{

}

[STAThread]
public static void Main()
{
Demo1();
}

private static void Demo1()
{
SqlConnection db = new SqlConnection("connstringhere");
SqlTransaction transaction;

db.Open();
transaction = db.BeginTransaction();
try
{
new SqlCommand("INSERT INTO TransactionDemo " +
"(Text) VALUES ('Row1');", db, transaction)
.ExecuteNonQuery();
new SqlCommand("INSERT INTO TransactionDemo " +
"(Text) VALUES ('Row2');", db, transaction)
.ExecuteNonQuery();
new SqlCommand("INSERT INTO CrashMeNow VALUES " +
"('Die', 'Die', 'Die');", db, transaction)
.ExecuteNonQuery();
transaction.Commit();
}
catch (SqlException sqlError)
{
transaction.Rollback();
}
db.Close();
}
}

As you can see from this example, we first open a connection to the SQL database. We then call the BeginTransaction method on the connection, keeping a reference to the object that it returns. At this point, the connection is bound to the SqlTransaction object that was returned. This means that any SqlCommand executed on that connection will be within the transaction. You can see, within the try block, we create and execute three SqlCommand objects. You’ll notice, though, that in this case we’re using the strings, SqlConnection, SqlTransaction, overload of the SqlCommand constructor. This is because the SqlCommand object requires passing in the transaction bound to a connection – failing to do so will cause an exception to be thrown. This is, in my opinion, a weakness of the model – since a transaction is bound on a per-connection basis, and a SqlCommand object should be able to simply pull the SqlTransaction object out of the supplied SqlConnection.

In the example above, the first two SqlCommand executes are perfectly valid – TransactionDemo exists in the database. The CrashMeNow table, however, does not. Since the table does not exist, a SqlException object will be thrown on ExecuteNonQuery object. It is important to realize that having a transaction "does not replace the standard exception handling mechanism". If you think your statements might not execute, you have to catch SqlException and, within your catch block, rollback the transaction.

There are essentially, two operations you can use on the SqlTransaction object. Rollback will cancel your transaction, undoing all the changes that have been made. Commit will cause the transaction to be written to the database permanently. Either case will end the transaction.

If you execute the code above and look at the TransactionDemo table, you’ll see that no rows have been added – the transaction was rolled back after the exception was thrown. If you remove the offending line of SQL, though, and run the program and look again, you’ll see that two rows have been added. That is, essentially, Transactions in action.

Advanced Transactions – isolation levels
This is not, though, the limit of transactions. As I stated earlier in my description of ACID properties, transactions don’t necessarily meet the strictest definition of Isolated. This is because the isolation level of a transaction is configurable by you, when you create the transaction.

Why would you want to do this? Performance. While full isolation is wonderful in theory, so was communism. In reality, exclusively locking a set of rows while a transaction works on them may be unfeasible due to performance – you don’t necessarily want to stop every reader in the system from reading a table because your transaction locked the whole thing.

To alleviate this concern .NET (through SQL Server), provides the ability to specify isolation levels when you create a transaction. Doing this simply requires supplying a System.Data.IsolationLevel value to the BeginTransaction method. The available values for SQL Server 2000 are:

ReadUncommitted – This is, essentially, no isolation. Anyone can read the data placed in a table or updated immediately after the SQL statement causes the change – no commit is required. This could lead to a process having out-of-date data: it may be using a version of the data that was then rolled back out of the table!
ReadCommitted – This is slightly more isolated. In this case, a transaction can only read data from the table that has already been committed. When a transaction wants to update data, it acquires a shared lock on that data and (if successful getting the lock) updates the data. Transactions outside of that transaction cannot update the data in that table until the locking transaction commits. This is only slightly more isolated, however: a SQL statement executed twice within a transaction could return a different result-set if a second transaction changes and commits the data the SQL statement executes on between the two statements. This is the default isolation level for SqlTransaction.
RepeatableRead – Slowly getting more isolated. In this case, a shared lock is applied on all data queried within a transaction. This means that no other transaction can alter the data used in your transaction. This prevents the case where data you had queried once changes on subsequent queries. It does not, though, prevent the case where rows are added to the table that may be returned in subsequent queries.
Serializable – Locks are placed on ranges of the tables you are using, preventing other users from changing your data or adding new rows underneath you. This is the most isolated isolation level, but it does come with the drawback of locking more data than your transaction may strictly need.
In SQL Server 2005, a new isolation level will be added: snapshot isolation. In snapshot isolation, rows are versioned once they are accessed in a transaction. This essentially means that once a transaction accesses a set of values, they are guaranteed to remain the same until you commit or rollback the transaction. Other transactions starting in the middle of the first will get a ‘copy’ of the original database to operate on. Before any transaction commits, though, SQL Server will test to ensure that the original data they were operating on is the same as the current data in the database. If this is the case, the transaction will commit. Otherwise, the transaction will be rolled back and the user will have to try the batch once again.

Conclusion
Transactions are useful for several other things. First, they provide a way to rollback a group of SQL statements if a single one should. Remember that failure can mean more than just an error being returned. A failure can also be logically related - in the example above, perhaps the account being transferred from doesn’t have enough money to do the deposit. In that case, you can roll back the transaction when you discover that fact. Secondly, they provide a way to isolate the data your transaction is working on so that you don’t have to worry about surprises. In all cases, though, you should examine what isolation level you really need and be aware of the performance implications of all of them.

INDEXER in C#

INDEXER IN C#:



In c# introduce new concept is Indexer. This is very useful for some situation. Let as discuss something about Indexer.


Indexer Concept is object act as an array.
Indexer an object to be indexed in the same way as an array.
Indexer modifier can be private, public, protected or internal.
The return type can be any valid C# types.
Indexers in C# must have at least one parameter. Else the compiler will generate a compilation error.
this [Parameter]

{

get

{

// Get codes goes here

}

set

{

// Set codes goes here

}

}



For Example:



using System;

using System.Collections.Generic;

using System.Text;



namespace Indexers

{

class ParentClass

{

private string[] range = new string[5];

public string this[int indexrange]

{

get

{

return range[indexrange];

}

set

{

range[indexrange] = value;

}

}

}



/* The Above Class just act as array declaration using this pointer */



class childclass

{

public static void Main()

{

ParentClass obj = new ParentClass();



/* The Above Class ParentClass create one object name is obj */



obj[0] = "ONE";

obj[1] = "TWO";

obj[2] = "THREE";

obj[3] = "FOUR ";

obj[4] = "FIVE";

Console.WriteLine("WELCOME TO C# CORNER HOME PAGE\n");

Console.WriteLine("\n");



Console.WriteLine("{0}\n,{1}\n,{2}\n,{3}\n,{4}\n", obj[0], obj[1], obj[2], obj[3], obj[4]);

Console.WriteLine("\n");

Console.WriteLine("ALS.Senthur Ganesh Ram Kumar\n");

Console.WriteLine("\n");

Console.ReadLine();

}

}

}

OOPs Concepts and .NET Part 1: Classes, Objects, and Structures

Summary

The following article kicks off a three-part article series that will present definitions and samples for different Object-Oriented Programming concepts and its implementation in .NET. The first part will examine the concepts of classes, objects, and structures. The second part will examine the concepts of inheritance, abstraction, and polymorphism. The third and last part will examine the concepts of interface, multiple interface inheritance, collections, and overloading.

Introduction

Object-Oriented Programming (OOP) is a software development paradigm that suggests developers to split a program in building blocks known as objects. The OOP paradigm allows developers to define the object's data, functions, and its relationship with other objects.

Microsoft created the .NET Framework using OOP, and knowing this concepts has helped me to understand the .NET Framework and to design and develop better software components. The purpose of this article is to describe the basic OOP concepts using real world scenarios and to provide some code samples that demonstrate how to work with OOP and .NET.

Class

The most common definition states that a class is a template for an object. Suppose that someone builds a paper pattern for a shirt. All the shirts done with the same paper pattern will be identical (same design, size, etc.). In this sample, the paper pattern is the class and the shirt is the object. To build the same exact shirt over and over, you need the paper pattern as a template. Another great example are house plans and blueprints. The plans and blueprints define the number of rooms, the size of the kitchen, the number of floors, and more. In this real world sample, the house plans and blueprints are the class and the house is the object. In OOP you program a class as a template for a specific object or groups ob objects that will always have the same features.

Class members

A class has different members, and developers in Microsoft suggest to program them in the following order:

Namespace: The namespace is a keyword that defines a distinctive name or last name for the class. A namespace categorizes and organizes the library (assembly) where the class belongs and avoids collisions with classes that share the same name.
Class declaration: Line of code where the class name and type are defined.
Fields: Set of variables declared in a class block.
Constants: Set of constants declared in a class block.
Constructors: A method or group of methods that contains code to initialize the class.
Properties: The set of descriptive data of an object.
Events: Program responses that get fired after a user or application action.
Methods: Set of functions of the class.
Destructor: A method that is called when the class is destroyed. In managed code, the Garbage Collector is in charge of destroying objects; however, in some cases developers need to take extra actions when objects are being released, such as freeing handles or deallocating unmanaged objects. In .NET, there is no concept of deterministic destructors. The Garbage Collector will call the Finalize() method at a non-deterministic time while reclaiming memory for the application.
Access keywords

Access keywords define the access to class members from the same class and from other classes. The most common access keywords are:

Public: Allows access to the class member from any other class.
Private: Allows access to the class member only in the same class.
Protected: Allows access to the class member only within the same class and from inherited classes.
Internal: Allows access to the class member only in the same assembly.
Protected internal: Allows access to the class member only within the same class, from inherited classes, and other classes in the same assembly.
Static: Indicates that the member can be called without first instantiating the class.
The following sample code illustrates a sample class in C#:

///Imported namespaces
using System;
/// Namespace: Consider using CompanyName.Product.ComponentType
namespace DotNetTreats.OOSE.OOP_CSharp {
///Class declaration
public class employee {
///Fields
private string _name;
private int _salary;
///Constants
private const int anualBonus = 1000;
///Constructor
public employee(){
}
///Properties
public string Name {
get {
return _name;
}
set {
_name = value;
}
}
public int Salary {
get {
return _salary;
}
set {
_salary = value;
}
}
/// Event handlers
public event EventHandler OnPromotion {
add {
}
remove {
}
}
/// Methods
public void DuplicateSalary()
{
_salary = _salary*2;
}
}
}

Listing 1. Sample class implementation in C#

The following sample code illustrates a sample class in VB.NET:

'Imported namespaces
Imports System
' Namespace: Consider using CompanyName.Product.ComponentType
Namespace DotNetTreats.OOSE.OOP_VBNET
'Class declaration
Public Class employee
'Fields
Private _name As String
Private _salary As Integer
'Constants
Private Const anualBonus As Integer = 1000
'Constructors
Public Sub New()
MyBase.New()
End Sub
'Properties
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = value
End Set
End Property
Public Property Salary() As Integer
Get
Return _salary
End Get
Set(ByVal Value As Integer)
_salary = value
End Set
End Property
' Event handlers
Public Event OnPromotion As EventHandler
'Methods
Public Sub DuplicateSalary()
_salary = (_salary * 2)
End Sub
End Class
End Namespace

Listing 2. Sample class implementation in VB.NET

Object

Objects are the building blocks of OOP and are commonly defined as variables or data structures that encapsulate behavior and data in a programmed unit. Objects are items that can be individually created, manipulated, and represent real world things in an abstract way.

Object composition

Every object is composed by:

Object identity: Means that every object is unique and can be differentiated from other objects. Each time and object is created (instantiated) the object identity is defined.
Object behavior: What the object can do. In OOP, methods work as functions that define the set of actions that the object can do.
Object state: The data stored within the object at any given moment. In OOP, fields, constants, and properties define the state of an object.
Structures

Not everything in the real world should be represented as a class. Structures are suitable to represent lightweight objects. Structures can have methods and properties and are useful for defining types that act as user-defined primitives, but contain arbitrary composite fields. The .NET Framework defines some structures such as System.Drawing.Rectangle, System.Drawing.Point, and System.Drawing.Color.

The following code sample represents a structures in C#:

struct Point
{
private int _x;
private int _y;
Point(int x, int y)
{
this._x = x;
this._y = y;
}
public int X
{
get
{
return _x;
}
set
{
_x = value;
}
}
public int Y
{
get
{
return _y;
}
set
{
_y = value;
}
}
}

Listing 3. Sample structure implementation in C#

The following code sample represents a structure in VB.NET:

Structure Point
Private _x As Integer
Private _y As Integer
Sub New(ByVal x As Integer, ByVal y As Integer)
MyBase.New()
Me._x = x
Me._y = y
End Sub
Public Property X() As Integer
Get
Return _x
End Get
Set(ByVal Value As Integer)
_x = value
End Set
End Property
Public Property Y() As Integer
Get
Return _y
End Get
Set(ByVal Value As Integer)
_y = value
End Set
End Property
End Structure

Listing 4. Sample structure implementation in VB.NET

Conclusion

OOP is full of abstract concepts, and the best approach to understand them is practical and not only theoretical. I learned more OOP after making some designs and after implementing some components. The concepts presented in this article might clarify the meaning, but I strongly recommend to go and have fun playing around with OOP. In this article, I examined the concept of classes, objects, and structs. The second part will examine the concepts of inheritance, abstraction, and polymorphism.

Reference

Matt Weisfeld, The Object-Oriented Thought Process, SAMS, 2000.
Don Box, Chris Sells, Essential .NET, Addison-Wesley, 2002.

OOPS Concepts and .NET Part 2: Inheritance, Abstraction, & Polymorphism

OOPS Concepts and .NET Part 2: Inheritance, Abstraction, & Polymorphism
By Erika Ehrli Cabral June 22, 2005

The following article is the second of a three-part article series that presents definitions and samples for different Object-Oriented Programming (OOP) concepts and its implementation in .NET.
Technologies: .NET Framework,Visual C# .NET
Total downloads : 565
Total page views : 158931
Rating :





4.29/5
This article has been rated : 14 times


Add to Technorati Digg This Add to del.icio.us


Download Files
OOPSamples.zip


Sponsored by


Looking for a book on C# Language? Here is our book




Description
A Programmer's Introduction to C# 2.0, Third Edition is a critical update to the highly successful second edition. It is written by a member of the original C# language-design team and a C# program manager, so you can be certain this book contains the expertise you're looking for.
Browse more books here»


Summary

The following article is the second of a three-part article series that presents definitions and samples for different Object-Oriented Programming (OOP) concepts and its implementation in .NET. The first part examined the concepts of classes, objects, and structures. This part examines the concepts of inheritance, abstraction, and polymorphism. The third and last part will examine the concepts of interface, multiple interface inheritance, collections, and overloading.

Introduction

In Part 1 of Object-Oriented Programming Concepts and .NET, I defined the concepts of class, object, and structure. In addition to defining the concepts, I explained real world samples and presented sample code in C# and VB.NET to create classes and structs. The first article also explains objects as independent building blocks.

In Part 2 of Object-Oriented Programming Concepts and .NET, I will explain the concepts of inheritance, abstraction, and polymorphism. I will also present a Unified Model Language (UML) class diagram to represent an object model that will help as a visual aid to explain some concepts. The purpose of this article is to explain a series of relationships between objects.

Inheritance

In the real world there are many objects that can be specialized. In OOP, a parent class can inherit its behavior and state to children classes. This concept was developed to manage generalization and specialization in OOP and is represented by a is-a relationship.

The following OO terms are commonly used names given to parent and child classes in OOP:

Superclass: Parent class.
Subclass: Child class.
Base class: Parent class.
Derived class: Child class
The most common real world sample to explain inheritance is the geometric shapes object model. Squares, circles, triangles, rectangles, pentagons, hexagons, and octagons are geometric shapes. The following figure shows a sample set of geometric figures:



Figure 1. Geometric shapes.

The concept of generalization in OOP means that an object encapsulates common state an behavior for a category of objects. The general object in this sample is the geometric shape. Most geometric shapes have area, perimeter, and color. The concept of specialization in OOP means that an object can inherit the common state and behavior of a generic object; however, each object needs to define its own special and particular state an behavior. In Figure 1, each shape has its own color. Each shape has also particular formulas to calculate its area and perimeter.

Inheritance makes code elegant and less repetitive. If we know that all shapes have color, should we program a color attribute for each shape? The answer is no! Would it be a better idea to create a shape class that has a color attribute and to make all the specialized shapes to inherit the color attribute? The answer is yes!

An object model for this sample could have a shape parent class and a derived class for each specific shape. The following UML class diagram shows the set of classes needed to model the geometric shapes sample. Observe the field, properties, and methods for each class:




Figure 2. The Shape class is the parent class. Square, Rectangle, and Circle are derived classes that inherit from Shape. The triangle-connector in the diagram represents an is-a relationship.

The .NET framework has many base classes. Everything is derived from System.Object. You can create almost anything you imagine using the built-in functionality provided in the .NET Framework Class Library.

To create a derived class in C#, the class declaration should be done as:

class child: parent

To create a derived class in VB.NET, the class declaration should be done as:

Class child
Inherits parent
End Class


Multiple inheritance

Multiple inheritance is the possibility that a child class can have multiple parents. Human beings have always two parents, so a child will have characteristics from both parents.

In OOP, multiple inheritance might become difficult to handle because it allows ambiguity for the compiler. There are programming languages such as C++ that allow multiple inheritance; however, other programming languages such as Java and the .NET Framework languages do not allow multiple inheritance. Multiple inheritance can be emulated in .NET using Multiple Interface Inheritance, which I will explain in Part 3 of this series.

Sealed class

A sealed class is a class that does not allow inheritance. Some object model designs need to allow the creation of new instances but not inheritance, if this is the case, the class should be declared as sealed.

To create a sealed class in C#, the class declaration should be done as:

sealed class Shape

To create a sealed class in VB.NET, the class declaration should be done as:

NonInheritable Class Shape

Abstraction

Abstraction is "the process of identifying common patterns that have systematic variations; an abstraction represents the common pattern and provides a means for specifying which variation to use" (Richard Gabriel).

An abstract class is a parent class that allows inheritance but can never be instantiated. Abstract classes contain one or more abstract methods that do not have implementation. Abstract classes allow specialization of inherited classes.

Figure 2 shows a Shape class, which is an abstract class. In the real world, you never calculate the area or perimeter of a generic shape, you must know what kind of geometric shape you have because each shape (eg. square, circle, rectangle, etc.) has its own area and perimeter formulas. The parent class shape forces all derived classes to define the behavior for CalculateArea() and CalculatePerimeter(). Another great example is a bank account. People own savings accounts, checking accounts, credit accounts, investment accounts, but not generic bank accounts. In this case, a bank account can be an abstract class and all the other specialized bank accounts inherit from bank account.

To create an abstract class in C#, the class declaration should be done as:

abstract class Shape

To create an abstract class in VB.NET, the class declaration should be done as:

MustInherit Class Shape

To following code shows a sample implementation of an abstract class:

/// C#
using System;
namespace DotNetTreats.OOSE.OOPSamples
{
public abstract class Shape
{
private float _area;
private System.Drawing.Color _color;
private float _perimeter;
public float Area
{
get
{
return _area;
}
set
{
_area = value;
}
}
public System.Drawing.Color Color
{
get
{
return _color;
}
set
{
_color = value;
}
}
public float Perimeter
{
get
{
return _perimeter;
}
set
{
_perimeter = value;
}
}
public abstract void CalculateArea();
public abstract void CalculatePerimeter();
}
}

Listing 1. The Shape abstract class in C#.

Polymorphism

Polymorphism allows objects to be represented in multiple forms. Even though classes are derived or inherited from the same parent class, each derived class will have its own behavior. Polymorphism is a concept linked to inheritance and assures that derived classes have the same functions even though each derived class performs different operations.

Figure 2 shows a Rectangle, a Circle, and Square. All of them are shapes and as shapes their area and perimeter can be calculated; however, each shape calculates its area in a specialized way. Declaring a member as abstract allows polymorphism. The Shape class defines the CalculateArea() and CalculatePerimeter() methods as abstract, this allows each derived class to override the implementation of the parent's methods.

To following sample code shows an implementation of a derived class (rectangle). The specific CalculateArea() and CalculatePerimeter() methods for the rectangle class illustrate polymorphism:

/// C#
using System;
namespace DotNetTreats.OOSE.OOPSamples
{
class Rectangle : Shape
{
private float _height;
private float _width;
public rectangle(float height, float width)
{
_height = height;
_width = width;
}
public float Height
{
get
{
return _height;
}
set
{
_height = value;
}
}
public float Width
{
get
{
return _width;
}
set
{
_width = value;
}
}
public override void CalculateArea()
{
this.Area = _height * _width;
}
public override void CalculatePerimeter()
{
this.Perimeter = (_height * 2) + (_width * 2);
}
}
}

Listing 2. Polymorphism represented in the Rectangle's methods.

Virtual keyword

The virtual keyword allows polymorphism too. A virtual property or method has an implementation in the base class, and can be overriden in the derived classes.

To create a virtual member in C#, use the virtual keyword:

public virtual void Draw()

To create a virtual member in VB.NET, use the Overridable keyword:

Public Overridable Function Draw()

Override keyword

Overriding is the action of modifying or replacing the implementation of the parent class with a new one. Parent classes with virtual or abstract members allow derived classes to override them.

To override a member in C#, use the override keyword:

public override void CalculateArea()

To override a member in VB.NET, use the Overrides keyword:

Public Overrides Function CalculateArea()

Conclusion

Inheritance allows developers to manage a generalization and specialization relationship between objects. OOP concepts such as abstraction and polymorphism help to define better object models where object hierarchies are designed with reusability in mind. In this article, I examined the concept of inheritance, abstraction, and polymorphism. The third and last part of this series will examine the concepts of interface, multiple interface inheritance, collections, and overloading.

Note: The sample source code* for this article works only in Visual Studio 2005.

Reference

Matt Weisfeld, The Object-Oriented Thought Process, SAMS, 2000.
Robin A. Reynolds-Haertle, OOP with Microsoft Visual Basic .NET and Microsoft Visual C# .NET Step by Step, Microsoft Press, 2002.

.Net Interview Questions

From Time to Time I go on a hunt for the Interview Questions,Hence I decided to consolidate all of them in one place,my blog!
1. 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 to the actual worker process aspnet_wp.exe.

2. What’s the difference between Response.Write() andResponse.Output.Write()?
Response.Output.Write() allows you to write formatted output.

3. What methods are fired during the page load?
Init() - when the page is instantiated
Load() - when the page is loaded into server memory
PreRender() - the brief moment before the page is displayed to the user as HTML
Unload() - when page finishes loading.

4. When during the page processing cycle is ViewState available?
After the Init() and before the Page_Load(), or OnLoad() for a control.

5. What namespace does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page

6. Where do you store the information about the user’s locale?
System.Web.UI.Page.Culture

7. What’s the difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?
CodeBehind is relevant to Visual Studio.NET only.

8. What’s a bubbled event?
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

9. Suppose you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler?
Add an OnMouseOver attribute to the button. Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");

10. What data types do the RangeValidator control support?
Integer, String, and Date.

11. Explain the differences between Server-side and Client-side code?
Server-side code executes on the server. Client-side code executes in the client's browser.

12. What type of code (server or client) is found in a Code-Behind class?
The answer is server-side code since code-behind is executed on the server. However, during the code-behind's execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser. But just to be clear, code-behind executes on the server, thus making it server-side code.

13. Should user input data validation occur server-side or client-side? Why?
All user input data validation should occur on the server at a minimum. Additionally, client-side validation can be performed where deemed appropriate and feasible to provide a richer, more responsive experience for the user.

14. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user's browser to another page or site. This performas a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.

15. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
Valid answers are:
• A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
• A DataSet is designed to work without any continuing connection to the original data source.
• Data in a DataSet is bulk-loaded, rather than being loaded on demand.
• There's no concept of cursor types in a DataSet.
• DataSets have no current record pointer You can use For Each loops to move through the data.
• You can store many edits in a DataSet, and write them to the original data source in a single operation.
• Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.

16. What is the Global.asax used for?
The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

17. What are the Application_Start and Session_Start subroutines used for?
This is where you can set the specific variables for the Application and Session objects.

18. Can you explain what inheritance is and an example of when you might use it?
When you want to inherit (use the functionality of) another class. Example: With a base class named Employee, a Manager class could be derived from the Employee base class.

19. What is an assembly?
Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN

20. Describe the difference between inline and code behind.
Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

21. Explain what a diffgram is, and a good use for one?
The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.

22. Whats MSIL, and why should my developers need an appreciation of it if at all?
MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL. MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer.

23. Which method do you invoke on the DataAdapter control to load your generated dataset with data?
The Fill() method.

24. Can you edit data in the Repeater control?
No, it just reads the information from its data source.

25. Which template must you provide, in order to display data in a Repeater control?
ItemTemplate.

26. How can you provide an alternating color scheme in a Repeater control?
Use the AlternatingItemTemplate.

27. What property must you set, and what method must you call in your code, in order to bind the data from a data source to the Repeater control?
You must set the DataSource property and call the DataBind method.

28. What base class do all Web Forms inherit from?
The Page class.

29. Name two properties common in every validation control?
ControlToValidate property and Text property.

30. Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?
DataTextField property.

31. Which control would you use if you needed to make sure the values in two different controls matched?
CompareValidator control.

32. How many classes can a single .NET DLL contain?
It can contain many classes.


Web Service Questions
1. What is the transport protocol you use to call a Web service?
SOAP (Simple Object Access Protocol) is the preferred protocol.

2. True or False: A Web service can only be written in .NET?
False

3. What does WSDL stand for?
Web Services Description Language.

4. Where on the Internet would you look for Web services?
http://www.uddi.org

5. True or False: To test a Web service you must create a Windows application or Web application to consume this service?
False, the web service comes with a test page and it provides HTTP-GET method to test.

State Management Questions
1. What is ViewState?
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.

2. 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).

3. 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.

4. 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
General Questions
1. Does C# support multiple-inheritance?
No.

2. Who is a protected class-level variable available to?
It is available to any sub-class (a class inheriting this class).

3. Are private class-level variables inherited?
Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

4. Describe the accessibility modifier “protected internal”.
It is available to classes that are within the same assembly and derived from the specified base class.

5. What’s the top .NET class that everything is derived from?
System.Object.

6. What does the term immutable mean?
The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.

7. What’s the difference between System.String and System.Text.StringBuilder classes?
System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

8. What’s the advantage of using System.Text.StringBuilder over System.String?
StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.

9. Can you store multiple data types in System.Array?
No.

10. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The first one performs a deep copy of the array, the second one is shallow. A shallow copy of an Array copies only the elements of the Array, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new Array point to the same objects that the references in the original Array point to. In contrast, a deep copy of an Array copies the elements and everything directly or indirectly referenced by the elements.

11. How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.

12. What’s the .NET collection class that allows an element to be accessed using a unique key?
HashTable.

13. What class is underneath the SortedList class?
A sorted HashTable.

14. Will the finally block get executed if an exception has not occurred?¬
Yes.

15. What’s the C# syntax to catch any possible exception?
A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

16. Can multiple catch blocks be executed for a single try statement?
No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

17. Explain the three services model commonly know as a three-tier application.
Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).

Class Questions
1. What is the syntax to inherit from a class in C#?
Place a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass

2. Can you prevent your class from being inherited by another class?
Yes. The keyword “sealed” will prevent the class from being inherited.

3. Can you allow a class to be inherited, but prevent the method from being over-ridden?
Yes. Just leave the class public and make the method sealed.

4. What’s an abstract class?
A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.

5. When do you absolutely have to declare a class as abstract?
1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
2. When at least one of the methods in the class is abstract.

6. What is an interface class?
Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.

7. Why can’t you specify the accessibility modifier for methods inside the interface?
They all must be public, and are therefore public by default.

8. Can you inherit multiple interfaces?
Yes. .NET does support multiple interfaces.

9. What happens if you inherit multiple interfaces and they have conflicting method names?
It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
To Do: Investigate

10. What’s the difference between an interface and abstract class?
In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.

11. What is the difference between a Struct and a Class?
Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.

Method and Property Questions
1. What’s the implicit name of the parameter that gets passed into the set method/property of a class?
Value. The data type of the value parameter is defined by whatever data type the property is declared as.

2. What does the keyword “virtual” declare for a method or property?
The method or property can be overridden.

3. How is method overriding different from method overloading?
When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.

4. Can you declare an override method to be static if the original method is not static?
No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)

5. What are the different ways a method can be overloaded?
Different parameter data types, different number of parameters, different order of parameters.

6. If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

Events and Delegates
1. What’s a delegate?
A delegate object encapsulates a reference to a method.

2. What’s a multicast delegate?
A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.

XML Documentation Questions
1. Is XML case-sensitive?
Yes.

2. What’s the difference between // comments, /* */ comments and /// comments?
Single-line comments, multi-line comments, and XML documentation comments.

3. How do you generate documentation from the C# file commented properly with a command-line compiler?
Compile it with the /doc switch.

Debugging and Testing Questions
1. What debugging tools come with the .NET SDK?
1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch.
2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.

2. What does assert() method do?
In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

3. What’s the difference between the Debug class and Trace class?
Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

4. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

5. Where is the output of TextWriterTraceListener redirected?
To the Console or a text file depending on the parameter passed to the constructor.

6. How do you debug an ASP.NET Web application?
Attach the aspnet_wp.exe process to the DbgClr debugger.

7. What are three test cases you should go through in unit testing?
1. Positive test cases (correct data, correct output).
2. Negative test cases (broken or missing data, proper handling).
3. Exception test cases (exceptions are thrown and caught properly).

8. Can you change the value of a variable while debugging a C# application?
Yes. If you are debugging via Visual Studio.NET, just go to Immediate window.

ADO.NET and Database Questions
1. What is the role of the DataReader class in ADO.NET connections?
It returns a read-only, forward-only rowset from the data source. A DataReader provides fast access when a forward-only sequential read is needed.

2. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix. OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as SqlServer.NET.

3. What is the wildcard character in SQL?
Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.

4. Explain ACID rule of thumb for transactions.
A transaction must be:
1. Atomic - it is one unit of work and does not dependent on previous and following transactions.
2. Consistent - data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.
3. Isolated - no transaction sees the intermediate results of the current transaction).
4. Durable - the values persist if the data had been committed even if the system crashes right after.

5. What connections does Microsoft SQL Server support?
Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).

6. Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?
Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.

7. What does the Initial Catalog parameter define in the connection string?
The database name to connect to.

8. What does the Dispose method do with the connection object?
Deletes it from the memory.
To Do: answer better. The current answer is not entirely correct.

9. What is a pre-requisite for connection pooling?
Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. The connection string must be identical.

Assembly Questions
1. How is the DLL Hell problem solved in .NET?
Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.

2. What are the ways to deploy an assembly?
An MSI installer, a CAB archive, and XCOPY command.

3. What is a satellite assembly?
When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

4. What namespaces are necessary to create a localized application?
System.Globalization and System.Resources.

5. What is the smallest unit of execution in .NET?
an Assembly.

6. When should you call the garbage collector in .NET?
As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice.

7. How do you convert a value-type to a reference-type?
Use Boxing.

8. What happens in memory when you Box and Unbox a value-type?
Boxing converts a value-type to a reference-type, thus storing the object on the heap. Unboxing converts a reference-type to a value-type, thus storing the value on the stack
Misc. questions:
1.Describe the difference between a Thread and a Process?
A1 - A thread is a path of execution that run on CPU, a proccess is a collection of threads that share the same virtual memory. A process have at least one thread of execution, and a thread always run in a process context.
2. What is strong-typing versus weak-typing? Which is preferred? Why?
A- Strong type is checking the types of variables as soon as possible, usually at compile time. While weak typing is delaying checking the types of the system as late as possible, usually to run-time. Which is preferred depends on what you want. For scripts & quick stuff you’ll usually want weak typing, because you want to write as much less (is this a correct way to use Ensligh?) code as possible. In big programs, strong typing can reduce errors at compile time.
1. What’s wrong with a line like this? DateTime.Parse(myString)
The result returned by this function is not assigned to anything, should be something like
varx = DateTime.Parse(myString)
2. What are PDBs? Where must they be located for debugging to work?
To debug precompiled components such as business objects (wow) ;-)) and code-behind modules, you need to generate debug symbols. To do this, compile the components with the debug flags by using either Visual Studio .NET or a command line compiler such as Csc.exe (for Microsoft Visual C# .NET) or Vbc.exe (for Microsoft Visual Visual Basic .NET).
1.Using Visual Studio .NET1. Open the ASP.NET Web Application project in Visual Studio .NET.
2. Right-click the project in the Solution Explorer and click Properties.
3. In the Properties dialog box, click the Configuration Properties folder.
4. In the left pane, select Build.
5. Set Generate Debugging Information to true.
6. Close the Properties dialog box.
7. Right-click the project and click Build to compile the project and generate symbols (.pdb files).
3. What is FullTrust? Do GAC’ed assemblies have FullTrust?
Your code is allowed to do anything in the framework, meaning that all (.Net) permissions are granted. The GAC has FullTrust because it’s on the local HD, and that has FullTrust by default, you can change that using caspol
4. What does this do? gacutil /l find /i “about”
This command is used to install strong typed assembly in GAC
5. What does this do? sn -t foo.dll
Don’t u know this dear? It will generate a strong name key for the foo.dll component!
6. Contrast OOP and SOA.
Service Oriented Architecture. In SOA you create an abstract layer that your applications use to access various “services” and can aggregate the services. These services could be databases, web services, message queues or other sources. The Service Layer provides a way to access these services that the applications do not need to know how the access is done. For example, to get a full customer record, I might need to get data from a SGL Server database, a web service and a message queue. The Service layer hides this from the calling application. All the application knows is that it asked for a full customer record. It doesn’t know what system or systems it came from or how it was retrieved.
7. Why is catch(Exception) almost always a bad idea?
Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project
8. What is the difference between Debug.Write and Trace.Write? When should each be used?
The Debug.Write call won’t be compiled when the DEBUG symbol is not defined (when doing a release build). Trace.Write calls will be compiled. Debug.Write is for information you want only in debug builds, Trace.Write is for when you want it in release build as well. And in any case, you should use something like log4net because that is both faster and better
9. What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
Debug build contain debug symbols and can be debugged while release build doesn’t contain debug symbols, doesn’t have [Contional(”DEBUG”)] methods calls compiled, can’t be debugged (easily, that is), less checking, etc. There should be a speed difference, because of disabling debug methods, reducing code size etc but that is not a guarantee (at least not a significant one)
10. Contrast the use of an abstract base class against an interface?
In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes
11. What is the difference between a.Equals(b) and a == b?
a equals b -> copies contents of b to a
a == b -> checks if a is equal to b
12. How would one do a deep copy in .NET?
System.Array.CopyTo() - Deep copies an Array
13. Is string a value type or a reference type?
String is Reference Type.
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short,strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap
14. What is a Windows Service and how does its lifecycle differ from a “standard” EXE?
Windows Service applications are long-running applications that are ideal for use in server environments. The applications do not have a user interface or produce any visual output; it is instead used by other programs or the system to perform operations. Any user messages are typically written to the Windows Event Log. Services can be automatically started when the computer is booted. This makes services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer. They do not require a logged in user in order to execute and can run under the context of any user including the system. Windows Services are controlled through the Service Control Manager where they can be stopped, paused, and started as needed.
15. How does the lifecycle of Windows services differ from Standard EXE?
Windows services lifecycle is managed by “Service Control Manager” which is responsible for starting and stopping the service and the applications do not have a user interface or produce any visual output, but “Standard executable” doesn’t require Control Manager and is directly related to the visual output.

Good Luck