开发者

No parametized types in C#?

Reading the Bruce Eckel book "Thinking in C#", to relearn C#, since I haven'y used it for many years but am likely to be needing it again soon.

I was surprised by this statement:

"In C++, the keyword that implements parameterized types is “template.” .NET currently has no parameterized types since it is possible for it to get by—however awkwardly—using the singly rooted hierarchy. However, there is no doubt that parameterized types will be implemented in a future version of the .NET Framework."

I think I remember reading somewhere that C# has generics - which are similar to C++ templates?

Am I wrong, or is the Eckel book simply too outdated (if so, is it worth still reading or is there a more up to date book online?)

[Edit]

Eeek, I'm glad I checked in here first. Looks like I'll have to throw that book away (written in 2002 I believe). Can anyone recommend any downloadable book that has the same depth of Eckels 'Thinking in ...' series?

There are a lot of C# books out there, but most of them are far too basic, or do not cover enough material. I was happy to find Eckel's book, since he covers C# in usual thorough style (from an introduction to OOP [which I don't need], through WinForm and Threading) - Unfortunately, it looks like its too old (Damn you MS for changing C# s开发者_高级运维pecs more times than I've had hot dinners!)

Can anyone recommend a good downloadable C# book that has a similar width/depth coverage?

[Edit 2]

Just seen this book:

http://www.free-ebooks-download.org/free-ebook/dotnet/CSharp/beginning-visual-csharp-2010.php

I'd like the opinion of this book from any professional C# developers out there ...


It's probably describing C# 1.0, which didn't have generics.

I would recommend finding a newer book that covers LINQ (introduced in C# 3) and dynamic (C# 4).


I would definitely get the most recent book that's relevant to the version of the .NET framework you're programming for. I started with an old book which didn't even cover automatic properties. Now one year later, I'm changing all of the previous code because it's so bloated and verbose.

Anyhow, C# does have generics, which as far as I can tell are the equivalent of C++ templates.


Generics are in C# since .NET 2.0, which came with Visual Studio 2005. The book is older than 5 years, you definetly need to get rid of it! :)


As others have noted, your book is out of date, or rather describes an out-of-date version of the framework.

It's interesting to note that the first language specification for C# published to ECMA for standardization included generics as a part of the language. C# 1.0 and 1.1, in not including generics, were not full implementations of the C# language. 1.0 and 1.1 should have been numbered 0.1 and 0.2 or some such, but Microsoft doesn't number things like that, as risk adverse people avoid doing real work with beta products.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜