473,326 Members | 2,732 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,326 software developers and data experts.

Won't compile: using IEnumerable<T> = System.Collections.Generic.IEnumerable<T>;

This won't compile:

using IEnumerable<T> = System.Collections.Generic.IEnumerable<T>;

namespace MyNamespace
{
public class MyClass<T> : IEnumerable<T>
{
// Appropriate stuff here
}
}

Is this by design? In other words, when using the classes and
interfaces of the System.Collections.Generic namespace, must I make an
exception to my normal coding style and change the above code to read:

using System.Collections.Generic;

namespace MyNamespace
{
public class MyClass<T> : IEnumerable<T>
{
// Appropriate stuff here
}
}

If so, then I'm kind of bummed. To make it easier for others to read
my code, I like to create using aliases for each type that I use
within a file, and to arrange the aliases alphabetically. Although
this practice seems anal, years of Java coding and reading others'
Java code made it clear to me that explicitly identifying the
namespaces (packages) of types makes it much easier for a reader to
figure out where a type is "coming from" whenever the reader
encounters a usage of a type within a file.

Thank you in advance.
Nov 16 '05 #1
6 4348
Hi Doug,

What is the System.Collections.Generic ???

try

using IEnumerable = System.Collections.IEnumerable;

and it will compile fine :)

What does the <T> mean?

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Morten,
What is the System.Collections.Generic ???
A new namespace in v2.0 with generic collections.

http://lab.msdn.microsoft.com/librar...ns_Generic.asp

What does the <T> mean?


That's a generic type parameter. See the v2 specification draft at

http://msdn.microsoft.com/vcsharp/te...e/default.aspx

or articles such as this one

http://msdn.microsoft.com/library/en...p_generics.asp

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #3
Ah, I wish people would stop using this group for beta questions, or at least specify v2.0 or whidbey in their questions :(

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #4
HI Doug:

You might get a better response in the Whidbey newsgroups:
http://communities.microsoft.com/new...idbey&slcid=us

--
Scott
http://www.OdeToCode.com

On 1 Aug 2004 21:04:23 -0700, do******@gmail.com (Doug Dew) wrote:
This won't compile:

using IEnumerable<T> = System.Collections.Generic.IEnumerable<T>;

<snip>
Nov 16 '05 #5
Thanks!

Scott Allen <bitmask@[nospam].fred.net> wrote in message news:<br********************************@4ax.com>. ..
HI Doug:

You might get a better response in the Whidbey newsgroups:
http://communities.microsoft.com/new...idbey&slcid=us

--
Scott
http://www.OdeToCode.com

Nov 16 '05 #6
do******@gmail.com (Doug Dew) writes:
This won't compile:

using IEnumerable<T> = System.Collections.Generic.IEnumerable<T>;

namespace MyNamespace
{
public class MyClass<T> : IEnumerable<T>
{
// Appropriate stuff here
}
}


A workable approach is to abbreviate the namespace:

using SCG = System.Collections.Generic;

namespace MyNamespace
{
public class MyClass<T> : SCG.IEnumerable<T>
{
// Appropriate stuff here
}
}

Peter
--
Department of Natural Sciences http://www.dina.kvl.dk/~sestoft/
Royal Veterinary and Agricultural University * Tel +45 3528 2334
Thorvaldsensvej 40, DK-1871 Frederiksberg C, Denmark * Fax +45 3528 2350
Nov 16 '05 #7

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

Similar topics

2
by: ESPNSTI | last post by:
Hi, I'm trying to use a generics dictionary with a key class that implements and needs IComparable<>. However when I attempt to use the dictionary, it doesn't appear to use the IComparable<> to...
4
by: matty.hall | last post by:
I have two classes: a base class (BaseClass) and a class deriving from it (DerivedClass). I have a List<DerivedClass> that for various reasons needs to be of that type, and not a List<BaseClass>....
10
by: jcc | last post by:
Hi guys, I'm a newbie to C#. My Visual Studio 2005 failed to compile the following code with error as 'HelloWorld.A' does not implement interface member...
0
by: clécio | last post by:
Hi folks! i developed a web custom control inherited from webcontrol, but when i try to bound a property using <%= %>, i have all the code put between de ' ! ex.: <uc1:SkinControlManager...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
1
by: Marc Boucher | last post by:
I'm using PG 7.3.4 I've a table with a column of type int8 where I store date-based values, and an index exists for it. The problem is that the index is almost never used with the '>' test. #...
9
by: Paul | last post by:
Hi, I feel I'm going around circles on this one and would appreciate some other points of view. From a design / encapsulation point of view, what's the best practise for returning a private...
2
by: -Karl | last post by:
Couls someone please advise me on this error. What I am trying to do is be able to convert an XML document into arrays. I read that the subs & functions have to be in <scripttags. Thanks! ...
6
by: Peter | last post by:
I have a WebService which returns a List of RunningReport class How do I read this XML data on the client side. How do I convert List<RunningReportfrom the WebService side to List<RunningReporton...
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...
1
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.