Article ID: 814907 - Last Review: December 11, 2006 - Revision: 2.4 You receive the "CS1513" and "CS1022" error messages when you use the volatile modifier on local variables in Visual C# .NET or in Visual C# 2005On This PageSYMPTOMSWhen you use the volatile modifier on local variables in Visual C# .NET or Visual C# 2005 code, you receive
the following compiler error messages: error CS1513: } expected error CS1022: Type or namespace definition, or end-of-file expected error CS0246: The type or namespace name 'STAThread' could
not be found (are you missing a using directive or an assembly
reference? CAUSEYou cannot use the volatile modifier on local variables or on function variables. Use the volatile modifier only with class variables. STATUS This
behavior is by design. WORKAROUND To work around this behavior, declare the volatile variables at class scope as follows: MORE INFORMATIONSteps to Reproduce the Behavior
| Article Translations
|
Back to the top
