Func<someType,someType=""> - What does the Equals sign mean? [closed]
Danny initially asked this question in response to a recent Scott Hanselman post:
Who can tell me what's this : Func<Customer, bool=""> A optional parameter with default value? A empty string for a bool? I replace it with Func, and get the different result in my machine! Everything works well, I get "where" statement wit开发者_JAVA技巧hout using Expression!
I know I've seen this Func madness, too, but I can't seem to get a Func<> or an Expression<Func<>> of this type to compile in C# 4.0.
Out of curiosity, what does the equals sign in the Func mean, if anything, and has that functionality been deprecated in C# 4.0?
[This question comes from Scott Hanselman’s blog: “The Weekly Source Code 52 - You keep using that LINQ, I dunna think it means what you think it means.”]
You say you've seen it... I doubt that you've seen it in code which compiles.
If you have, please give an example: because until I see real code that way, I'm 99% sure it's just not valid C#.
According to the Visual C# 4.0 Language Specification, the ISO C# Language Specification (which is a subset of Visual C# 2.0), the Visual Studio 2010 Syntax Highlighter and the Visual C# 4.0 Compiler, this is not legal C# code. It isn't even syntactically legal, i.e. it doesn't even parse, let alone semantically legal.
Therefore, it simply doesn't mean anything.
I think you need to read Scott's answer in the comments, his blog software was playing up.
Nothing to see here!!
- ^ What Matt says. Few things to watch for using SyntaxHighlighter in blog:
(1) http://bitbucket.org/alexg/syntaxhighlighter/issue/154/c-brush-lacks-c-3-and-4-keywords
Bug #154 C# brush lacks C#3 and 4 keywords - group, orderby, from, var, select, ascending, descending, into, join, let, dynamic, add, remove, where (resulting in some LINQ syntax issues)
(2) hxxp://bitbucket.org/alexg/syntaxhighlighter/issue/165/using-in-code-produces
Bug #165 Using < and > in code produces < and ="">
Note: Be careful to use: <script type="syntaxhighlighter" class="brush: csharp">
(3) Yes Alex (SyntaxHighlighter) knows about it:
hxxp://alexgorbatchev.com/forums/comments.php?DiscussionID=200&page=1#Item_0
Forum thread: LINQ not working in C#
I doubt it's valid.
Even if Func
supported optimal arguments, the last type argument is the result.
精彩评论