Microsoft KB Archive/315740

= FIX: You receive an &quot;Error CS1513&quot; error message when you try to compile code that is generated by the Implement Interface Wizard in Visual Studio .NET =

Article ID: 315740

Article Last Modified on 8/24/2005

-

APPLIES TO


 * Microsoft Visual Studio .NET 2002 Professional Edition

-



This article was previously published under Q315740



SYMPTOMS
The code generated by the Implement Interface Wizard does not compile correctly. Instead, you receive the following error message:

c:\my samples\q315740\class1.cs(37,2): error CS1513: } expected



CAUSE
This behavior occurs only with a class that derives from an interface and for which no methods or properties are implemented as yet.

The Implement Interface code generator places the closing curly brace for the class in the same line as the #endregion directive. The #region directive lets you specify a block of code that you can expand or collapse when you use the outlining feature of the Visual Studio Code Editor.



RESOLUTION
To resolve this issue, move the curly brace next to the #endregion directive.

NOTE: If a method or property were already implemented in your class, you would not encounter this issue.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual Studio .NET (2003), Professional Edition.



Steps to Reproduce the Problem
 Create a new C# console application.  Add an empty class that implements an interface. Make sure that no methods or properties are defined. Also, make sure that you have referenced the assembly that defines the interface. For example: //Add the following to the top of your file using System.Collections; class Class2 : IEnumerable { }                     Go to ClassView. Open the Class2 node, open the Bases and Interfaces node underneath it, and then select the IEnumerable interface. Right-click, point to the Add menu, and then click Implement Interface.

The following code should be generated: public System.Collections.IEnumerator GetEnumerator {           return null; }       #endregion}//<--- Take this curly brace to the next line  Compile the application.
 * 1) region Implementation of IEnumerable

Keywords: kberrmsg kbbug kbfix kbnofix kbvs2002sp1sweep KB315740

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.