Day Dreaming

"A daydream is a visionary fantasy experienced while awake, especially one of happy, pleasant thoughts, hopes or ambitions."[Ref:Wikipedia]

Getting a job..

Hola Guyz..firstly got a job as a .NET Developer and so far its been pretty good. I shifted to a new place and will just talk about my recent events.
I got a job finally and more importantly so far I have got to learn a lot and also all the people including my BOSS have been really good..in fact it’s been pretty good and I have had a good time. Hopefully everything continues well and will learn along the way. I moved to a different place as could not stay there anymore. But it is funny that everytime you move from a place to other you tend to at least I do think of all the moments spent there…and all the things happened..Personally I had a good time…Bethany apt will always stay and it was a lovely place…where I learned and focused myself better to what I needed…and to sum it was great…
Now, it’s the first time that I would be living without Doyle and Pratik who have been together with me so far In US but I guess this had to happen sometime…and I am happy everyone is moving for a good reason…things in life always change..with time you make new memories…but these past moments are always good…and I feel just really content to have good friends..and lucky to got all the love…hopefully..the road ahead is as good…and I am going to do my best….Live my life..the right way…the happy way…adios..
Life isn’t about finding yourself. Life is about creating yourself.
George Bernard Shaw

Life in Allen and Everyday..:)

Hey guys…back to blogging again after a long hiatus…well what reasons can I give for not blogging and again failing to stick to my plans…well unfortunately none of them may hide my laziness and drifting at times…anyways..it’s never too late to start…and will keep coming back…but this time no promises and predefined plans..:)
I am just going to talk about the past 3 months here in Allen TX, I have been applying for jobs and learning asp.net for the major part of this period…at times been boring as it is been little mundane but I think I have been learning quite a few things…and been much more focused compared to Houston..well also drifting at times as mentioned to some of my problems which I have overblown and just thought too much….one thing I should do I believe is at least do my best in the few things I am doing and enjoy the process…at times however hard it maybe...I know these motivational talks are boring…but at times it helps to analyze and see where I am going…
I think we all need motivation sometimes we get it automatically if we are really into doing something…but if you are not that much interested and are forced at times...it is good I guess to find ways in which you can keep working and motivating yourself..So, that was basically reasons behind me trying to learn ASP.NET in 35 days  and finishing those last few topics in I don’t know how much time …but I am really happy I did it because it at least kept me motivated for sometime…and I got to learn quite a few things in process which are important for me..
The trouble at times is I think too much…and got into this habit unknowingly it kills me at times helps me…but I have learnt that everyone has problems and there are people with bigger problems who still are cheerful..not whining and giving reasons…So our job is to live life to the fullest and not worry too much of the outcomes at times…don’t know what I have blabbered over in this post...but all I wanted to convey or stress was life’s is good if you want it to be…its never going to be perfect but you should always keep working at it.…your biggest enemy and best friend will always be in you..So its up to you who you let out…

If you want to be happy, be. ~Leo Tolstoy

Day 2,3 - AJAX Continued...and Code...

***Disclaimer: I have got these information from varied sources and for some of them have been referenced directly from Sams teach yourself ASP.NET Ajax in 24 hrs.***
Ajax-enabled controls are ASP.NET server controls built by wiring the client components to the ASP.NET server controls.

Extenders are external objects that are wired with ASP.NET server controls to get the Ajax behavior, and script controls are server controls created as Ajaxenabled controls that specify both the server and client capabilities at the same place.

An extender is built by declaring a class that inherits from the base class ExtenderControl. This class should implement the interface IExtenderControl. Doing this registers the extender with the ScriptManager control.
AutoComplete is an ASP.NET Ajax extender that can be wired to any TextBox control, to display a suggested list of words in a pop-up panel with the prefix typed into the text box.

The ConfirmButton extender is used to attach itself to a Button control or any type derived from it, which prompts the user with a confirm dialog before submitting the page to the server. The DropDown extender attaches itself to a Label and Panel control to get a drop-down menu. The advantage of having this extender is that the Panel to which we are wiring up the extender can hold any type of server controls and not only link buttons. This provides the option to innovate with this extender.

Web Parts
Web parts are a set of server controls that are available in ASP.NET 2.0 that allow you to componentize your page into manageable sections. You can edit, move around holding the web part, change its settings at runtime, and can completely personalize your web page.
A web part page must have a WebPartManager and at least one web part zone. All the customization of content in the custom web part needs to be done dynamically from the code-behind file. The designer feature for customizing web parts is not available. Because you cannot customize the content in the web part from the design view, it is always suggested that you customize all the content of the web part in a user control or a custom control and add this control to the web part.

Client-side callbacks, a feature introduced by Microsoft in ASP.NET 2.0, allow controls to execute HTTP requests using JavaScript to obtain data on the server without posting the entire page.
For an Ajax operation to be performed, a control must implement the ICallbackEventHandler interface.
The PageRequestManager class belongs to the Sys.WebForms namespace and is responsible for managing the sequence of events for an asynchronous postback. When you mix callbacks and postbacks in your Ajax-enabled ASP.NET applications, you might encounter PageRequestManager
ParserErrorException. This error occurs when the response object is modified due to calls to Response.Write() and Response.Redirect() and usage of response filters and HttpModules.
ValidatorCalloutExtender is used in conjunction with a RequiredFieldValidator to validate the input data in a control. The following code uses this extender to validate the textbox txtProductName.
TextBoxWatermarkExtender is used to notify the user with a message in the textbox. The user needs to mention the textbox name in the attribute TargetControlID. When the textbox gets focus, the message is automatically wiped out.

http://www.box.net/shared/ga0dxmnjeg

DAY 1 : AJAX - Introduction and Components

AJAX
Why and What is ASP.NET Ajax?
**Disclaimer: I have got these information from varied sources and for some of them
have been referenced from Sams teach yourself ASP.NET Ajax in 24 hrs. **

AJAX (Asynchronous JavaScript) mainly allows you to perform partial updates to the page and also asynchronous postback which gives the users interactive and slick feel. Now, With AJAX, a JavaScript can communicate directly with the server, with the XMLHttpRequest object. With this object, a JavaScript can trade data with a web server, without reloading the page. You can find tutorial to AJAX at w3schools which takes you to all the basic concepts you need to know about AJAX. To provide partial page rendering we have two other options first using IFrame but it is a synchronous operation that causes the portion of the page to reload and flicker. And second, the client-side script needs to be written for hiding or showing the IFrame, when dynamic loading of a portion of the page is to be handled on an event. The second method using XMLHttpRequest object but isn’t the best, as the logic has to be moved from the server to client. Also, the browser incompatibility issues come into the picture when using the XMLHttp protocol. Thus using update panel and other ASP.NET Ajax is the best option.
How AJAX works?
Important blocks or services for which ASP.NET 2.0 has support:
- The Membership API - The Membership API in ASP.NET 2.0 enables you to manage the users and roles of an application.
- The Profile API -The ASP.NET 2.0 Profile API can be used to store profile information for both authenticated and anonymous users and make it available to the application for the user’s subsequent visits to the application.
- The Personalization API - The ASP.NET 2.0 Personalization API enables you to personalize your application seamlessly. You can use this API to customize the user profiles, themes, error pages of your application
The ASP.NET AJAX server extensions framework includes the following components:
- Application Services Bridge - This component is used to provide access to the application services available as part of ASP.NET 2.0 from client-side scripts. The basic services provided by this bridge include, but are not limited to, the following:
o User authentication using the Membership API
o Storage of user’s data using the Profile API
- The Web Services Bridge - The web services bridge is used to consume external web services from the client side in an Ajax-enabled web application. Web services have already been explained in the previous section. The web services bridge makes use of the JSON serializer, JavaScript proxies, and the .asbx files or the bridge files to call the web services.

ASP.NET AJAX Controls-
- Timer
- ScriptManager
- ScriptManagerProxy
- UpdateProgress
- UpdatePanel

Timer - Using the Timer control, you can set a timer for your web page. You can ensure that the web page can post back to the web server after a specified interval of time. You can use the Interval property of this control to set an interval in milliseconds, after which the web page will refresh itself. Once this interval elapses, the control fires a post back to the web server. This is how the mark-up code of a typical Timer control looks:


Script Manager – (Brain of an Ajax-Enabled Web Page) - Manages Microsoft ASP.NET 2.0 Ajax extensions script libraries and script files, partial-page rendering, and client proxy class generation for web and application services.
Script ManagerProxy - ScriptManagerProxy control enables you to add scripts and services that are specific to nested components. You should have a ScriptManager control in a web page that has a ScriptManagerProxy control, or else an InvalidOperationException error. If you need to register a script that is not part of Script manager control we can use Script ManagerProxy to add these scripts.



- Update Progress Control – (Displaying Progress Status During Partial Updates) - The UpdateProgress control can be used to display the progress status when using partial-page rendering in an Ajax-enabled ASP.NET web page.
...
- The UpdatePanel Control – (Facilitating Partial Page Updates) - The UpdatePanel control included as a part of the Ajax server extensions framework is used to update only a specified portion of the web page. This feature is what is commonly known as partial-web page rendering.

Setting the UpdateMode property to Conditional is advisable because it improves the performance of the web page considerably by sending only the data that is to be updated in the page.
A trigger is an event that causes the UpdatePanel to refresh its content. This event can be generated by any control in the form. There are two types of triggers:
- AsyncPostBackTrigger - The AsyncPostBackTrigger fires an asynchronous postback event on the UpdatePanel control. The child control’s postback of the UpdatePanel by default fires this trigger. There are two attributes associated with the AsyncPostBackTrigger: ControlID and EventName.
- PostBackTrigger - There might be situations where a button is clicked in an UpdatePane, and it requires the entire web page to be posted back. In such scenarios, we can go ahead with the PostBackTrigger. This trigger does not have an EventName property.
You can have one and only one ScriptManager control in your Ajax-enabled web page.

Restart...

Hey guys,firstly sorry but could not keep up to what I promised and let myself down.But really had other important things and was getting little too difficult to devote that much time. But sometime in future i will cover the remaining topics..So I have decided to restart with a different approach this time.

I have decided I will try to put topics more important for me to learn..I have decided to study some topics which are quite important and hopefully will help you all too. These are the topics I will try to cover -
1. ASP.NET AJAX
2. WCF
3. Web Services
4. WPF
5. SQL Reporting Services
6. Silverlight
7. XML/XSLT

These are the topics I decided not in that order and maybe will add more later. But these are more than enough right now for me to learn. I have decided that I will be giving each topic 3 days...and try to cover all the important points and aspects..
One of the things I have thought is to answer 3 questions - WHY ? WHAT ? HOW?
By answering these questions...for e.g AJAX...Why AJAX?....What is AJAX?...HOW AJAX WORKS?....I feel it will help to understand better...its just my point of view...As it is anyway impossible to cover every aspect I will cover the important concepts.
Okies so all said and done...I will be covering AJAX starting from today...23rd Feb to 25 Feb...and will then move with WCF or Web Services...Signing out...

“Failure is simply the opportunity to begin again, this time more intelligently.” - Henry Ford

Day -13 : Chapter 15 Introduction to Assemblies


Chapter 15 deals with Assemblies and their configuration.
Properties of assemblies -
·         Assemblies Promote Code Reuse
·         Assemblies Establish a Type Boundary
·         Assemblies Are Versionable Units
·         Assemblies Are Self-Describing
·         Assemblies Are Configurable
A .NET assembly (*.dll or *.exe) consists of the following elements:
·         A Win32 file header - The Win32 file header establishes the fact that the assembly can be loaded and manipulated by the Windows family of operating systems. This header data also identifies the kind of application to be hosted by the Windows operating system.
·         A CLR file header - The CLR header is a block of data that all .NET files must support  in order to be hosted by the CLR. In a nutshell, this header defines numerous flags that enable the runtime to understand the layout of the managed file.
·         CIL code - At its core, an assembly contains CIL code, which as you recall is a platform- and CPU-agnostic intermediate language. At runtime, the internal CIL is compiled on the fly (using a just-in-time [JIT] compiler) to platform- and CPU-specific instructions. Given this architecture, .NET assemblies can indeed execute on a variety of architectures, devices, and operating systems.
·         Type metadata - An assembly also contains metadata that completely describes the format of the contained types as well as the format of external types referenced by this assembly. The .NET runtime uses this metadata to resolve the location of types (and their members) within the binary, lay out types in memory, and facilitate remote method invocations
·         An assembly manifest - An assembly must also contain an associated manifest (also referred to as assembly metadata). The manifest documents each module within the assembly, establishes the version of the assembly, and also documents any external assemblies referenced by the current assembly.
·          Optional embedded resources - Finally, a .NET assembly may contain any number of embedded resources such as application icons, image files, sound clips, or string tables.
Private Assemblies - Private assemblies are required to be located within the same directory as the client application. The full identity of a private assembly consists of the friendly name and numerical version, both of which are recorded in the assembly manifest.
The .NET runtime resolves the location of a private assembly using a technique termed probing, which is much less invasive than it sounds. Probing is the process of mapping an external assembly request to the location of the requested binary file.
Shared Assemblies - The most obvious difference between shared and private assemblies is the fact that a single copy of a shared assembly can be used by several applications on a single machine. You cannot install executable assemblies (*.exe) into the GAC. Only assemblies that take the *.dll file extension can be deployed as a shared assembly.
<codeBase>  - Application configuration files can also specify code bases. The <codeBase> element can be used to instruct the CLR to probe for dependent assemblies located at arbitrary locations. If the value assigned to a <codeBase> element is located on a remote machine, the assembly will be downloaded on demand to a specific directory in the GAC termed the download cache. Given what you have learned about deploying assemblies to the GAC, it should make sense that assemblies loaded from a <codeBase> element will need to be assigned a strong name.
System.Configuration Namespace - The System.Configuration namespace provides a small set of types you may use to read custom data from a client’s *.config file. These custom settings must be contained within the scope of an <appSettings> element. The <appSettings> element contains any number of <add> elements that define a key/value pair to be obtained programmatically.
Machine Configuration File - The .NET platformmaintains a separate *.config file for each version of the framework installed on the local machine. If you were to open this file, you would find numerous XML elements that control ASP.NET settings, various security details, debugging support, and so forth. However, if you wish to update the machine.config file with machinewide application settings.

Day 8-12 : Chapter 14: Introduction to LINQ

Hey Guyz..really trailing my original plan and way lot to cover...As also I have been swamped with my other things..its really getting tough..but will give it my best..and go into overdrive mode now. Anyways..moving on with the book..we have next LINQ-
LINQ is Language Integrated Query. LINQ is a set of related technologies that attempts to provide a single, symmetrical manner to interact with diverse forms of data. As explained LINQ can interact with any type implementing the IEnumerable<T> interface, including simple arrays as well as generic and non generic collections of data.
The LINQ API is an attempt to provide a consistent, symmetrical manner in which programmers can obtain and manipulate “data” in the broad sense of the term. Using LINQ, we are able to create directly within the C# programming language entities called query expressions. These query expressions are based on numerous query operators that have been intentionally designed to look and feel very similar (but not quite identical) to a SQL expression.
LINQ query expressions is that they are not actually evaluated until you iterate over their contents. Formally speaking, this is termed differed execution.
When you wish to evaluate a LINQ expression from outside the confines of foreach logic, you are able to call any number of extension methods defined by the Enumerable type to do so. Enumerable defines a number of extension methods such as ToArray<T>(), ToDictionary<TSource,TKey>(), and ToList<T>(), which allow you to capture a LINQ query result set in a strongly typed container.
The OfType<T>() method is one of the few members of Enumerable that does not extend generic types. When calling this member off a nongeneric container implementing the IEnumerable interface (such as the ArrayList), simply specify the type of item within the container to extract a compatible IEnumerable<T> object.
You can also use Lambda operators for building queries. For e.g. –
var subset = currentVideoGames.Where(game => game.Length > 6).OrderBy(game => game) .Select(game => game);
General Syntax for LINQ Query - var result = from item in container select item;
LINQ query expressions can return any number of result sets, it is common to make use of the var keyword to represent the underlying data type. As well, lambda expressions, object initialization syntax, and anonymous types can all be used to build very functional and compact LINQ queries. More importantly, you have seen how the C# LINQ query operators are simply shorthand notations for making calls on static members of the System.Linq.Enumerable type.
As shown, most members of Enumerable operate on Func<T> delegate types, which can take literal method addresses, anonymous methods, or lambda expressions as input to evaluate the query.

Day 6,7 - Chapter 13: C# Language Features - Code

Holla Everyone,
I have attached code for the chapter. I will not be able to do for Chapter 12
but should be easy. Also two of the files have Main() so you need to remove one or
run one at a time. Cheers!
http://www.box.net/shared/ol5lun1y49
http://www.box.net/shared/0r7o52qfpj
http://www.box.net/shared/pucgu2op8l

Day 6,7 - Chapter 13: C# Language Features


This chapter deals with various other C# features and a relatively simple chapter. I will post the code for this chapter and for previous one together in the next post. Sorry but have been procrastinating little.
Implicity Typed Variables - C# 2008 includes implicitly typed local variable, now provides a new keyword  var, which you can use in place of specifying a formal data type and it will be assigned a type based on its initialization. It is illegal to use the var keyword to define return values, parameters, or field data of a type. Be very aware that implicit typing of local variables results in strongly typed data.

Automatic Properties - In C# we have automatic properties. Automatic property syntax -
public string PetName { get; set; }. We can also restrict access to automatic properties using protected and private properties. Also when we use automatic properties the variables are set to default values e.g. int to 0 and ref variable to NULL.

Extension Methods - Extension methods allow existing compiled types as well as types currently being compiled to gain new functionality without needing to directly update the type being extended. There are two conditions to be followed firstly the methods must be declared within a static class and methods must have this modifier.

Partial Methods  - Partial methods allows you to prototype a method in one file, yet implement it in another file. Restrictions on Partial methods –
• Partial methods can only be defined within a partial class.
• Partial methods must return void.
• Partial methods can be static or instance level.
• Partial methods can have arguments (including parameters modified by this, ref, or params—but      not with the out modifier).
• Partial methods are always implicitly private.

Object Initializer Syntax -  Using this technique, it is possible to create a new type variable and assign a slew of properties and/or public fields in a few lines of code. e.g.
 var yetAnotherPoint = new Point() { X = 30, Y = 30 }; - Default Constructor
var yetAnotherPoint = new Point(12,34) { X = 30, Y = 30 }; -Custom Constructor
We can also initialize collections in similar way.

Anonymous types - When you define an anonymous type, you do so by making use of the new var keyword in conjunction with the object initialization syntax. All anonymous types are automatically derived from System.Object E.g. –
var myCar = new { Color = "Bright Pink", Make = "Saab", CurrentSpeed = 55 };
Anonymous types have following iterations –
• You don’t control the name of the anonymous type.
• Anonymous types always extend System.Object.
• The fields and properties of an anonymous type are always read-only.
• Anonymous types cannot support events, custom methods, custom operators, or custom
overrides.
• Anonymous types are always implicitly sealed.
• Anonymous types are always created using the default constructor.

Also, Since they derive from object they can have the methods of Object Class.Compiler-generated Equals() method makes use of value-based semantics when testing for equality (e.g., checking the value of each field for the objects being compared).

Day 5: Chapter 12: Indexes, Operators and Pointers

This Chapter is relatively simple and deals with Indexes,Operators and Pointers.

Indexer Methods - In its simplest form, an indexer is created using the this[] syntax. You can use intergers or even string to represent indexers. For e.g. following gives a function to represent using strings – public Person this [string name] {get {} set {}} We can also overload indexer methods , can have them on interfaces and also have multi dimensional arrays.
Operator Overloading- You can perform operator overloading . E.g Overloading an addition operator for a class point with two variables can be done–
public static Point operator + (Point p1, Point p2)
You can overload all kinds of operator’s unary, binary or comparison and other operators.
Custom Conversions - Also consider conversion between two classes which do not have a same parent. In order to perform this we can use either implicit or explicit conversion. Declare a explicit conversion using the following syntax-
public static explicit operator
public static implicit operator
Working with pointers - When you wish to work with pointers in C#, you must specifically declare a block of “unsafe code” using the unsafe keyword. Once you have established an unsafe context, you are then free to build pointers to data types using the * operator and obtain the address of said pointer using the ‘&’ operator.

The rest of the chapter mainly deals with '->' operator,fixed,sizeof and preprocessor directives. These last concepts have already been done in C and hence I am not going into details.

Delegates,Events and Lambdas and - Code

Hey Guys..I have not been keeping up with the pace i decided..so I am going to try and do better..I have not implemented Generic Delegates and Anonymous methods and Lambda Operators. Here are the links-

http://www.box.net/shared/ac7djgnr5z
http://www.box.net/shared/nyapktb7b5

Day 3,4 - Delegate,Events and Lambdas


Sorry..but really could not complete it on time. Also there are quite a few things that you may still require to read from other sources. Personally I found it difficult to complete this chapter.
Delegates- In essence, a delegate is a type-safe object that points to another method (or possibly a list of methods). E.g. This delegate can point to any method taking two integers and returning an integer.                      
public delegate int BinaryOp(int x, int y);
When the C# compiler processes delegate types, it automatically generates a sealed class deriving from System.MulticastDelegate. For the above example C# compiler will generate following code in bold are the items specified in declaration-
sealed class BinaryOp : System.MulticastDelegate
{
public BinaryOp(object target, uint functionAddress);
public int Invoke(int x, int y);
public IAsyncResult BeginInvoke(int x, int y,
AsyncCallback cb, object state);
public int EndInvoke(IAsyncResult result);
}
BeginInvoke() and EndInvoke() provide the ability to call the current method asynchronously on a separate thread of execution. Invoke() is perhaps the core method, as it is used to invoke each method maintained by the delegate type in a synchronous manner, meaning the caller must wait for the call to complete before continuing on its way. Further Multicast delegate derives from Delegate class which implements ICloneable and ISerializable. Also, it is not possible to directly derive from these classes.
A simple delegate example will be explained  in the code you can also determine NET delegates are type safe. Therefore, if you attempt to pass a delegate a method that does not “match the pattern,” you receive a compile-time error. Also,
Multicasting - When you wish to add multiple methods to a delegate object, you simply make use of the overloaded += operator, rather than a direct assignment. The Delegate class also defines a static Remove() method that allows a caller to dynamically remove a member from the invocation list.
Delegate Covariance - Given the laws of classic inheritance, it would be ideal to build a single delegate type that can point to methods returning either Car or SportsCar objects (after all, a SportsCar “is-a” Car). Covariance (which also goes by the term relaxed delegates) allows for this very possibility. Simply put, covariance allows you to build a single delegate that can point to methods returning class types related by classical inheritance.
In a similar vein, contravariance allows you to create a single delegate that can point to numerous
methods that receive objects related by classical inheritance. Consult the .NET Framework 3.5 SDK documentation
for further details.
Generic Delegates - We can also have Generic Delegates . For e.g. This generic delegate can call any method  returning void and taking a single parameter.
public delegate void MyGenericDelegate(T arg)

Events in ASP.NET  - You can declare a event using ‘event’ keyword when compiler processes the event keyword, you are automatically provided with registration and unregistration methods as well as any necessary member variables for your delegate types. These delegate member variables are always declared private, and therefore they are not directly exposed from the object firing the event and hence overcome the problem with delegates. To be sure, the event keyword is little more than syntactic sugar in that it simply saves you some typing time. Defining an event is a two-step process. First, you need to define a delegate that will hold the list of methods to be called when the event is fired. Next, you declare an event (using the C# event keyword) in terms of the related delegate. A C# event actually expands into two hidden public methods, one having an add_ prefix, the other having a remove_ prefix.
C# Anonymous Methods - It is possible to associate a delegate directly to a block of code statements at the time of event registration. Formally, such code is termed an anonymous method. You must terminate the method with a semicolon. Anonymous methods are interesting in that they are able to access the local variables of the method that defines them. Formally speaking, such variables are termed outer variables of the anonymous method.
C# 2008 Lambda Operator - Lambda expressions are nothing more than a more concise way to author anonymous methods and ultimately simplify how we work with the .NET delegate type. You can use the operator ‘=>’ and declare anonymous method after it.

Chapter 10 : Collections and Generics - Code


Hi Everyone forgot to mention the types you should mention when specifying a constraint using where keyword the following table illustrates more -
Generic                                                                                    Constraint Meaning in Life
where T : struct                                     The type parameter must have System.ValueType in its chain of inheritance.
where T : class                                      The type parameter must not have System.ValueType in its chain of                                                             inheritance (e.g., must be a reference type).
where T : new()                                     The type parameter must have a default constructor. This is very helpful if your generic type must create an instance of the type parameter, as you cannot assume the format of custom constructors. Note that this constraint must be listed last on a multiconstrained type.
where T : NameOfBaseClass                   The type parameter must be derived from the class specified by NameOfBaseClass.
where T : NameOfInterface                     The type parameter must implement the interface specified by NameOfInterface.Multiple interfaces can be separated as a comma-delimited list.
Program Code- 

Day 2: Chapter 10- Collections and Generics


Holla, back with next chapter this one is little vast so I cannot mention every detail..but I have tried to cover all the important points.So, Chapter 10 basically deals with Collections and generics in ASP.NET.
Collections – We have different types of collections and System.Collections has following Interfaces –
ICollection- Defines general characteristics (e.g., size, enumeration, thread safety) for all nongeneric collection types.
IComparer Allows two objects to be compared.
IDictionary Allows a nongeneric collection object to represent its contents using name/value pairs.
IDictionaryEnumerator- Enumerates the contents of a type supporting IDictionary.
IEnumerable- Returns the IEnumerator interface for a given object.
IEnumerator - Enables foreach style iteration of subtypes.
IHashCodeProvider - Returns the hash code for the implementing type using a customized hash algorithm.
IList - Provides behavior to add, remove, and index items in a list of objects. Also, this interface defines members to determine whether the implementing collection type is read-only and/or a fixed-size container.
Class Types of System.Collections –
ArrayList – Represents a dynamically sized array of objects
Hashtable - Represents a collection of objects identified by a numerical key Custom types stored in a Hashtable should always override System. Object.GetHashCode().
Queue - Represents a standard FIFO Queue.
SortedList - Like a dictionary; however, the Like a dictionary; however, the by ordinal position (e.g., index).
Stack - A last-in, first-out (LIFO) queue.I would use all these types in code.
Boxing and Unboxing – Boxing basically means converting a shorter(for e.g. Short) type in a wider type(for e.g. Object)..and unboxing is converting it back. Also, if you cast a value in wrong type you will get an invalidcastexception. To know more please visit here- http://www.codersource.net/csharp_boxing_unboxing.html
The problems without Generics –
1.    As a new object is allocated on managed heap and can lead to wastage of memory which in bigger application may be a problem.
2.    Type Safety – It is the property which operates on a particular type. You can create a type safe collection but if you need to use derived class objects we need to create another similar type collection or there will be a compile-time error and hence creating different methods for each and this can be a tedious task.
Generics Benefits –
1.    Generics provide better performance, as they do not result in boxing or unboxing penalties.
2.    Generics are more type safe, as they can only contain the “type of type” you specify.
3.    Generics greatly reduce the need to build custom collection types, as the base class library provides several prefabricated containers.
By convention, generic types specify their placeholders using common names. Although any letter (or word) will do, typically T is used to represent types, TKey is used for keys, and TValue is used for values.System.Collections.Generics has following Interfaces-
• ICollection
• IComparer
• IDictionary
• IEnumerable
• IEnumerator
• IList
We can create custom generic methods refer to swap method for example of it. We can also create interfaces which can have generics as parameters. For e.g. a interface which adds and subtracts numbers it can perform this for any numerical type using generics. Similarly we can have generic classes and structures.
The "default" keyword is overloaded in C# when used with generics; it represents the default value of a type parameter. Constraints are applied using the where keyword, the constraint list is placed after the generic type’s base class and interface list. e.g.
// MyGenericClass derives from MyBase and implements ISomeInterface,while the contained items must be structures.
public class MyGenericClass : MyBase, ISomeInterface where T : struct
We can also have base generic classes and interfaces, a derived class needs to specify a parameter type for T.To know more about Generics –
Code will be uploaded by early morning...:)

Chapter 9: Program Code

Hi Everyone following are files you can add them to a new project and run your application.
The interface files really dont have any code...they are just most for the undertsanding. Cheers..will try
to post better examples..next time..I haven't implemented Callback Interfaces due to time constraint.

http://www.box.net/shared/rhb0tzqvye
http://www.box.net/shared/2hie3h9n03
http://www.box.net/shared/2b8syugy79
http://www.box.net/shared/odsav6l7rl
http://www.box.net/shared/khuzlafzov

DAY 1:CHAPTER 9 WORKING WITH INTERFACES

Ok Guyz..,First Post..So I am going to cover everything worth a mention in the Chapter and also attach a sample code with comments for understanding. Also as I mentioned the Book for reference APRESS PRO C#2008 .NET 3.5 Platform I am going to throw in my own ideas and contribute my knowledge and experience also…and I am assuming you have read first chapters before…
So, Chapter 9 basically deals with interfaces…and other important concepts include...Enumerable types, Cloneable Objects, Comparable objects and Callback interfaces.
Now, Interfaces can be declared using keyword interface…for e.g. interface IMyInterface . Use ‘I’ prefix as a conventions…You can add a new class from visual studio and create interface as there is no separate option to do so ...Here are few points worth mentioning –
One or more interfaces can be implemented by classes hence provide multiple inheritance indirectly. Also they help to isolate and unlike deriving classes (with abstract methods) you can choose which interface to implement.
By Default, it cannot have any variables or instance members can have only methods which are abstract and public and remember you will get an error if you try to make them public or abstract again explicitly.
It is illegal to – instantiate an interface object or have a constructor for interface.
Differences between Abstract Class and Interface-
1.    Abstract class may have implementation of methods but interface can have only declarations.
2.    Also Abstract class can have other members’ types but interfaces can have only abstract methods.
To determine if a type supports a specific interface is to make use of an explicit cast and then use  a try/catch or you could use the ‘as’ keyword or ‘is’ keyword. I would cover this with example code attached. Also Interface could be used as Parameters, Return types, also we can have arrays of interfaces.
Interfaces can be arranged into an interface hierarchy. Like a class hierarchy, when an interface extends an existing interface, it inherits the abstract members defined by the parent type(s).
Also if you implement two interfaces with a method with the same name you can use for e.g. We have IMyInterface1 and IMyInterface2 with method1(). You should implement using IMyinterface1.method1() to implement it. Refer to code example for implementation of these concepts.
Moving further, we have building enumerable types (IEnumerable and IEnumerator).Now we have foreach construct which can be used by classes which have implemented IEnumerable and  GetEnumerator() method. For e.g. System.Array can use it directly. But for custom classes and other classes we have following two ways-
1.    Implementing the IEnumerable interface and providing definition.(we have to use using System.Collections). Simply put, an iterator is a member that specifies how a container’s internal items should be returned when processed by foreach.
2.    You can just implement public IEnumerator GetEnumerator() method which iterates over the sub-items using internal foreach logic and returns each object to the caller using the yield return syntax.
Cloning – We can have deep or shallow copy of objects and we need to implement Icloneable  Interface and implement MemberwiseClone() and Clone() methods both return shallow copy of objects. To know more about cloning in .NET refer here - http://www.codeproject.com/KB/dotnet/Clone.aspx
Comparing Objects –
We have the IComparable interface with CompareTo() method which you can provide your own logic and use the Sort() method to sort the custom objects array. To Sort multiple objects we can use IComparer interface and provide implementation of Compare(obj1,obj2) which will then by using  Sort() method sort two different objects.
Callback Interfaces- 
Beyond using interfaces to establish polymorphism across diverse class hierarchies, namespaces,and assemblies, interfaces may also be used as a callback mechanism. This technique enables objects to engage in a two-way conversation using a common set of members.Callback interfaces are often not implemented by the object directly interested in receiving the events, but rather by a helper object called a sink object.
Unfortunately, I am still working on the code and the files will be uploaded by tomorrow morning…