c# - Is there a way, at design time, to initialize an object with all properties in Visual Studio 2010? -



c# - Is there a way, at design time, to initialize an object with all properties in Visual Studio 2010? -

background

i writing code in vs 2010, .net 4, c#. also, in case matters, using latest version of resharper.

question

let's have model:

public class someobject { public string red{ get; set; } public string green{ get; set; } public string blue{ get; set; } public string yellow{ get; set; } public string purple{ get; set; } public string orange{ get; set; } public string black{ get; set; } }

elsewhere in code, need instantiate 1 of these objects, so:

someobject myobject = new someobject{ reddish = "some value", bluish = "some other value", . . ., black="last value" };

*note:*i want initialize object subset of total possible properties (i.e. reddish , blue).

at moment, having type in each property (red, blue, green, etc) each new instance of someobject. there hotkey or in vs2010 have properties pre-populated have assign values each rather typing each one?

at moment, having type in each property (red, blue, green, etc) each new instance of someobject.

personally, if need set these every object instance, handle adding constructor takes of parameters, , not utilize object initialization syntax. give total intellisense, help/force build object correctly every time.

remember, type's constructor should forcefulness supply parameters required correctly initialize object proper state. 1 downside object initializers don't forcefulness @ compile time. such, if of these properties required each object instance, constructor should supply them instead of using object initializers.

c# visual-studio-2010 resharper

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -