Showing posts with label ref and out are not valid in this context. Show all posts
Showing posts with label ref and out are not valid in this context. Show all posts

Monday, July 27, 2015

Workaround for the syntax error in C#:ref and out are not valid in this context

Recently I was  trying  to implement the interface Microsoft.Office.Interop.Word.Styles.
public Style this[ref object Index]
        {
          
        }

Visual Studio through  this error ":ref and out are not valid in this context"

Workaround :
//public Style this[ref object Index] // error CS0631: ref and out are not valid in this context
public Style get_Item(ref object Index)
{
    . . .
}