Declare Properties (C#)
In This Article
Generates auto-implemented properties for an object initializer expression. Places the cursor on the last generated property declaration, and drops a marker onto the initial property reference.
Note
The code provider is only available for .NET framework 3.
#Availability
From the context menus or via shortcuts:
- when the edit cursor or caret is on a reference to any property within the object initializer expression.
#Example
public class ClassA
{
}
class TestClass
{
private void TestMethod()
{
ClassA objVar = new ClassA() { │prop1 = 12, prop2 = "Name", };
}
}
Result:
public class ClassA
{
public int prop1 { get; set; }
public string │prop2 { get; set; }
}
class TestClass
{
private void TestMethod()
{
ClassA objVar = new ClassA() { prop1 = 12, prop2 = "Name", };
}
}