Template Metaprograms in c#?

Posted on 2005-04-21
Last Modified: 2010-04-16
I used to do Template Metaprograms in C++ but i dont see this feature in C#. Is there a way to do it?
I am trying to create a generic function which takes a reffrence to either datagrid, datalist or repeater  and binds it to the datareader. It is the the same function which applies to datagrid, datalist and repeater. Any suggestions?
Question by:Carl3003
    1 Comment
    LVL 48

    Accepted Solution

    Templates will be available in C# 2005.
    Currently the best thing available is to find some common base class for all supported classes and write code for it. When necessary, make types check and call functions specific to some class.
    For example, .NET collections work with object type, this allows to keep any type in collection. It is like writing some generic code in C++ using void* pointer.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now