473,242 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

C# 3.0: no additions to where clause? dang.

I was hoping for increased functionality with the where clause in C#
3.0. Using the new keyword 'var' would really allow us to take nice
advantage of these. Specifically:

1. I want to limit it to primitives: "where T : System.Type.Primitive"
or something like that.
2. I want to limit it to an unspecified generic: "where T : List<>".
3. I want to limit it to a generic with a subset of types: "where T :
List<new TTwhere TT : class" or something similar.
4. I want to limit to a class with a certain property or method: "where
T : interface MyFunc(int), interface operator+=(int), interface get
MyProperty(int)" or something similar.
5. I want a default type: "where T default(MyType): IMyType" or
something similar so that I don't have to specify the type in all
situations. If it leads to ambiguous functions, throw an error.
6. Specify a namespace: "where T in System : class" or something like
that.
7. I want to AND/OR the conditions for the where clause together.

Thoughts? Comments? Complaints?

Jan 11 '07 #1
1 2742

"not_a_commie" <no********@gmail.comwrote in message
news:11*********************@i56g2000hsf.googlegro ups.com...
>I was hoping for increased functionality with the where clause in C#
3.0. Using the new keyword 'var' would really allow us to take nice
advantage of these. Specifically:

1. I want to limit it to primitives: "where T : System.Type.Primitive"
or something like that.
"where T : primitive" would be very nice, I agree
2. I want to limit it to an unspecified generic: "where T : List<>".
Just make S the generic parameter, you can use List<Sthroughout your
generic class
3. I want to limit it to a generic with a subset of types: "where T :
List<new TTwhere TT : class" or something similar.
Same as #2
4. I want to limit to a class with a certain property or method: "where
T : interface MyFunc(int), interface operator+=(int), interface get
MyProperty(int)" or something similar.
Since generics are shared between all reference types, this would only be
possible for type parameters restricted to value types. In that case it
would be extremely useful and perfect for generic arithmetic.

Would have to be syntax like:
where T : value having operator+=(T,T=>T)
5. I want a default type: "where T default(MyType): IMyType" or
something similar so that I don't have to specify the type in all
situations. If it leads to ambiguous functions, throw an error.
C# in general doesn't have default arguments but uses overloaded functions
to get the same user experience.

Generics can be overloaded based on the number of type arguments. So you
get what you're looking for with
public class Hashmap<T: Hashmap<string, T>
6. Specify a namespace: "where T in System : class" or something like
that.
7. I want to AND/OR the conditions for the where clause together.
The constraints are always and'ed, because if the compiler generates calls
in MSIL, the methods have to be available.

What would be useful would be constraint overloading:

class StableSortedList<T{ /* use a stable sort */ }
class SortedList<T{ /* use the fastest sort */ }
class StableSortedList<T: SortedList<T>
where T : ITotalOrdering, T : IUnique { /* if elements can never compare
equal, then needn't use the expensive stable sort algorithm */ }

The problem I see with that is that while the compiler could pick that
easily, it would tend not to propagate through other generics :(
>
Thoughts? Comments? Complaints?

Jan 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: middletree | last post by:
I have no idea what's going on. The more I use Access, the more I hate it. But for this church project, I have to use it. (I'm used to SQL Server) It was working fine, adding and inserting and...
3
by: A.V.C. | last post by:
Hello, I found members of this group very helpful for my last queries. Have one problem with CASE. I can use the column name alias in Order By Clause but unable to use it in WHERE CLAUSE. PLS...
29
by: C A Upsdell | last post by:
Comments re these three related, proposed CSS 3 additions? 1. Add 'text-transform:time', which would transform text in the format hours:minutes:seconds (24 hour clock) to the local format for...
6
by: Cro | last post by:
Dear Access Developers, The 'Allow Additions' property of my form is causing unexpected results. I am developing a form that has its 'Default View' property set to 'Continuous Forms' and am...
5
by: Mr. SweatyFinger | last post by:
Hi my checkbox list works great, except when i go to edit the items in the browser. It doesn't save the changes. This routine is supposed to save the newly checked items, instead it saves out...
2
by: Jim.Mueksch | last post by:
I am having a problem with using calculated values in a WHERE clause. My query is below. DB2 gives me this error message: Error: SQL0206N "APPRAISAL_LESS_PRICE" is not valid in the context where...
9
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
5
by: pwiegers | last post by:
Hi, I'm trying to use the result of a conditional statement in a where clause, but i'm getting 1)nowhere 2) desperate :-) The query is simple: -------- SELECT idUser,...
20
by: billmaclean1 | last post by:
I need to write a stored procedure that selects from a table and returns the result set. I don't always know the TableSchema that I need to use when qualifying the table at run-time Example:...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.