Re: Problems compiling a lambda expression



On Sat, 26 Jul 2008 10:39:17 -0700, K Viltersten <tmp1@xxxxxxxxxxxxxx> wrote:

I've got a hint from a gentleman here to use the
following syntax.

public static FileInfo[]
GetFilesRegExp(this DirectoryInfo di, string pat)
{
Regex re = new Regex(pat);
return Array.FindAll(
di.GetFiles(),
(f) => re.IsMatch(f.Name));
}

The problem is that the compiler seems to dislike
"this" in the argument list as well as "goes to"
in the lambda expression.

What's up with that and how do i kill it?

What errors are you getting _exactly_. Writing "the compiler seems to dislike" doesn't explain your problem at all.

As far as the "this", I expect that either you're not using C# 3.0 or you're trying to declare the method in a non-static class. But without knowing the error, it's hard to say for sure which or whether either is correct.

I don't see anything obviously wrong with the lambda expression, but again...if you're not using C# 3.0, then it wouldn't work.

Knowing the actual error message would help a _lot_. Frankly, that's always going to be true if you are asking about help with errors that occur, either during compilation or execution.

Pete
.



Relevant Pages

  • Re: Problems compiling a lambda expression
    ... in the lambda expression. ... Writing "the compiler seems to ... Is the upgrade ... to the latest version of the framework free of charge if ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: port I/O abstraction macros
    ... without knowing how to write a compiler, ... get a B.S.C.S without knowing how to design an FM radio. ... an FM radio unless you are directly going into Sony's Radio Compiler ...
    (comp.arch.embedded)
  • Re: port I/O abstraction macros
    ... Radio Compiler division. ... real world than knowing how to parse an arithmetic expression. ... they need is to build some sort of primitive lexer. ...
    (comp.arch.embedded)
  • Re: Code problems with Perform Thru Exit causes fall through
    ... Evrybody has a verb or two that they dislike. ... which the compiler gives no warning of. ... that is often used to protect poor programming styles. ...
    (comp.lang.cobol)
  • Re: port I/O abstraction macros
    ... an FM radio unless you are directly going into Sony's Radio Compiler ... Knowing what a compiler does and the sort of tricks current ... there are no more tokens to read. ...
    (comp.arch.embedded)