-1
votes
1answer
69 views

Pros and cons of using generic delegates as nested functions

I've written code like this before: private void Strings_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { var onAdd = new Action(() => { if(e.NewItems != ...
1
vote
2answers
107 views

Implementing a generic/dynamic custom property system in C#

I have an architecture design problem which I think is appropriate for this site. General problem description: My primary goal is to design a software library/program (C#) to automate a very ...
1
vote
1answer
96 views

Implement Generic DataSet Builder with C#

I want to create a data access library that can build a DataSets with relations which can easily be written to XML with dataset.WriteXML(). This is a get to know C# endeavor that will hopefully gain ...
9
votes
2answers
441 views

Why is there a new() constraint in C# but no other similar constraint?

In C# generics, we can declare a constraint for a type parameter T to have a default constructor, by saying where T : new(). However, no other kinds of constraints like this are valid - new(string) ...
11
votes
2answers
499 views

How are generics implemented?

This is the question from compiler internals perspective. I am interested in generics, not templates (C++), so I marked the question with C#. Not Java, because AFAIK the generics in both languages ...
-1
votes
2answers
262 views

Generics vs IoC [closed]

One of the "Service Locator" pattern drawbacks is that a caller can be misleaded about dependencies of a callee. Ok, but what if I put dependencies as generic parameters at a class level: class ...
1
vote
4answers
470 views

How to figure out design pattern for this particular solution?

While working on a project I've come up with some design solution. I am having a hard time relating it to any general design pattern or analyzing this situation in details. This is also prohibiting me ...
2
votes
1answer
2k views

Adding base-class (inherited) functionality to classes that you don't control

I have a set of classes from a 3rd party library. These classes use an inheritance structure to share logic. I would like to add a layer of abstraction in the middle of their inheritance tree to add ...
0
votes
2answers
157 views

Similar references to themselves in two classes

How can I make 1 class (base, generic or something else) from these two classes? class A { A Link { get; set; } } class B { B Link { get; set; } } UPD: This is what I have now: class BSTree { ...
3
votes
5answers
2k views

What problems can be solved using Generics?

I haven't used Generics in C# for a long while. Every time I think I need to use them I either go in the wrong direction and give up or find that I don't really need them. I feel that I'm missing out ...
3
votes
7answers
656 views

Protecting the uninitiated (developer) from generics

Is it acceptable to have a dummy generic parameter in the parameters list in order to save method consumers from the need to specify type arguments? For example - public T Generate<T>(int ...
8
votes
3answers
7k views

Difference between various Collection Generic Interfaces in C#

I have been playing around with C# for Windows and ASP.net MVC development for some time now. But I am still unclear on a few areas. I am trying to understand the basic difference between and ...
8
votes
5answers
2k views

What's a good naming convention for generic types in C#? [closed]

I decided to ask this question here instead of on stack overflow because it is rather subjective. In C#, typically I see generic types with very poor names. Specifically, "T" is commonly used but is ...