.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Post New Web Links

Pure C++: Reflecting on Generic Types

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

A funny thing happened to templates on their way to the common language runtime (CLR)-they lost their {type} identity. This is analogous to what happens with macros under native programs. Just as the C/C++ compilers have no awareness of macro preprocessor expansions, the CLR has no awareness of template instantiations.

Stanley B. Lippman

MSDN Magazine December 2005

View Complete Post

More Related Resource Links

Pure C++: Invoking Generic or Function Templates


As I promised last time, in this month's column I'll walk through the process of defining and invoking a generic or template function under C++\CLI. A function template or a generic function begins with the template or generic keyword followed by its parameter list.

Stanley B. Lippman

MSDN Magazine October 2005

Pure C++: Generic Programming: Template Specialization


As I discussed in my last column, a param-eterized type that does more than simple storage and retrieval is constrained as to the acceptable types that may be safely bound to it (see Pure C++: CLR Generics Versus C++ Templates.

Stanley B. Lippman

MSDN Magazine August 2005

Pure C++: Generic Programming Under .NET


Visual Studio® 2005 brings the type parameter model of generic programming to the Microsoft® . NET Framework. Parameterized types are, of course, standard fare for C++ programmers. So, for those who are unfamiliar with them, I'll give a brief introduction to generic programming in my next few columns.

Stanley B. Lippman

MSDN Magazine April 2005

Confusion about web service return types (classes, generic list)?


I have confusion about web service return types? Can a webservice return a genelist? ex: List(Of Employees)

I have searched threads in this forums but got confused, some say 'yes' some say 'no'.

If I mark the class as Serizable will that be enough to return a generic list?


Can generic types be used as WCF method parameters?


Hello everyone, help me plz with one question...

If it`s possible, i would want to know some way for passing generic type as income parameter of WCF service method. In fact, i want pass a lambda expression to use it for filtering data on next tier of application. It`s needed for my own realization of custom paging data on web page, i have already found the way to pass custom SortExpression and SortOrder (and create in other place lambda expression from then for using in OrderBy/OrderByDescending). ALso i have founded the way to pass to web application only one, exactly needed page of data with full illusion of large collection objects, than also supports sorting. The last thing want is to add possibility of filtering data, and for this task it would be great to create lambda expression and pass it to the next tier for using in Where() expression before my other actions for custom paging.

I created generic datacontract that contains property of type System.Linq.Expressions.Expression<Func<TSource, bool>>, and used if as a parameter of wcf method as MyDataContract<MyCustomType>. Project compiles well, even starting (it`s a wcf service hosted in application and installed as service), but i cannot update service reference to it, it shows "The server was unable to process the request due to an internal error" page. I think, may be some prob

How to constrain a generic class to a subset of types



I'm working on a application which downloads updates automatically based on defined filters and system values. One of the support classes for these filters which I am developing, FilterValue class, can support various types of values such as dates, booleans, singles, doubles, strings, list of strings, lists of singles, list of dates, ranges of singles, ranges or dates, etc (currently 64+ supported types). Ideally what I would like to do is build one class, and using Generics constrain the types which can be used, ideally I would like to do something like this:


//I know that this is not a proper generic constraint
public class FilterValue<T> where T: int OR string OR List<string> OR etc
  //The filter value
  public T value;


I could use abstract classes and inheritance but I rather avoid having to write 64+ separate classes for maintainability reasons.

loading generic types with late binding




  I'm trying to late bind a generic datatype at runtime.  Basically the assembly for this generictype is in a different directory (not a sub directory).  So I can't use private probing.  Its not reliably in the GAC either, so I can't depend on that.  I can load several other types from this assembly but not this generic type.


So in the assembly the datatype is of the form MyGenericDataType

and at runtime I want the type of MyGenericDataType.


Any idea how to do that?  I tried:


Code Block

Assembly MyAssembly = Assembly.LoadFile("Path to assembly DLL");


Type MyType = MyAssembly.GetType("MyGenericDataType<MyRegularDataType>");




MyType always equals null.


Do I need to load MyGenericDataType first and then somehow convert it to MyGenericDataType ?



SharePoint Tutorial - Content Types

SharePoint content types provide users with a way to manage and organize content in a more meaningful way. It's a reusable of settings you want to apply to a particular type of document in a library or item in a list.

Creating a Generic Entity Framework 4.0 Repository

With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework.

The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to SQL. To set things right, Microsoft proactively moved forward with improving Entity Framework, in time for the 4.0 release of the .NET Framework. This is good news because my initial impressions, so far, have been nothing but positive.

A Generic Dialog ViewModel

I worked on a wpf viewmodel for dialogs, because it seemed strange to me that you needed for instance windows forms dialogs to open or save files in wpf. So I set about creating my own wpf dialogs. After creating the dialog viewmodels there still remained a small issue with the library and also I didn't have much time to write an article about it. I however published the library containing the viewmodels for dialogs with another article on my blog

UML Diagram Types

UML provides a number of diagram types as a mechanism for entering model elements into the model and showing overlapping sets of models elements and their relationships. UML does not specify what diagrams should be created or what they should contain, only what they can contain and the rules for connecting the elements. The diagram types include:

UML Diagram Types - 2

Further diagram types include:

Activity Diagrams - a generic flow chart used much in business modelling and sometimes in use case modelling to indicate the overall flow of the use case. This diagram type replaces the need for dataflow diagrams but is not a main diagram type for the purposes of analysis and design.

Ready made List Types provided by SharePoint

SharePoint provides some out of the box List Types. Some of the most used ready made list types that SharePoint provides currently are listed below:

Tuples, Anonymous Types, and Concrete Types

Tuples can save you a great deal of repetitive tasks. They can also lead to completely unreadable code in a language like C#. Tuples are data values that contain N items. The .NET framework supports tuples containing 1 to 8 members. To use tuples with more than 8 members, you use another tuple for the member of an octtuple

Content Types in MOSS 2007

In this article I will try to describe the one of the best feature in Microsoft office Share Point 2007 called Content Types.

Content types are simply collection of contents.Each content in a Content type can have different settings.Basically it is a reusable collection of settings which you want to apply to a particular category of contents.

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.

Different types of applications in WPF

With Windows Presentation Foundation coming closer to its release date with Vista almost being upon us, more and more people are taking a look at programming in WPF
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend