Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C#
C# Reference
 Compiler Error CS1673
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual C# Reference: Errors and Warnings
Compiler Error CS1673

Anonymous methods, lambda expressions, and query expressions inside structs cannot access instance members of 'this'. Consider copying 'this' to a local variable outside the anonymous method, lambda expression or query expression and using the local instead.

The following sample generates CS1673:

// CS1673.cs
delegate int MyDelegate();

public struct S
{
   int member;

   public int F(int i)
   {
       member = i;
       // Try assigning to a local variable
       // S s = this;
       MyDelegate d = delegate()
       {
          i = this.member;  // CS1673
          // And use the local variable instead of "this"
          // i =  s.member;
          return i;
           
       };
       return d();
   }
}

class CMain
{
   public static void Main()
   {
   }
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker