C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







C# Generics Samples


Posted Date: 23 Oct 2007    Resource Type: Articles    Category: .NET Framework

Posted By: Kumar       Member Level: Silver
Rating:     Points: 10



Here’s some sample code I wrote. My class has a member variable typed dataset You can actually reduce the number of lines of code you write, check this out. My humble beginnings in generics:


[Serializable]
[XmlTypeAttribute(Namespace = “Generic.Lib”)]
class GenericCode where T : System.Data.DataSet
{
#region Private members
private T input;
#endregion

#region Properties
public T Input
{
get { return input;}
set { input = value; }
}
#endregion

#region Constructor
///
/// Constructor
///
public GenericCode()
{
}
#endregion

# region Methods
void ExecuteCommand()
{
if (input != null)
{
DAL.ExecuteStoredProc(input); //contacting the Data Access Layer
}
else
{
throw new ArgumentNullException(”Information is not present.”);
}
}
#endregion
}

To use the class above I need to pass my typed dataset as type:
GenericCmd< MyTypedDataset > cmd = new GenericCmd< MyTypedDataset >();

Generic classes can inherit from concrete, closed constructed, or open constructed base classes.

Cheers!!!





Responses

Author: Tony John    05 Nov 2007Member Level: Gold   Points : 0
Good one, Kumar. This is a better candidate for the Code Factory section rather than Article section.


Author: Kumar    10 Nov 2007Member Level: Silver   Points : 0
Thanks man!!!


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Strings in C#
Previous Resource: About CLR and its functionalities
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use