Hello everyone,

I want to know that is there any advantage of using Object Initializer?

For ex. i have code like this:

Code:
                SqlParameter nodeparameter = new SqlParameter();
                nodeparameter.ParameterName = "@nodevalue";
                nodeparameter.SqlDbType = SqlDbType.VarChar;
                nodeparameter.Size = parentnodeid.Length;
                nodeparameter.Direction = ParameterDirection.Input;
                nodeparameter.Value = strSplit[1];
                myCommand.Parameters.Add(nodeparameter);
It is working fine, but i have write this code in an other way, like this:

Code:
                SqlParameter nodeparameter = new SqlParameter
               {
                ParameterName = "@nodevalue",
                SqlDbType = SqlDbType.VarChar,
                Size = parentnodeid.Length,
                Direction = ParameterDirection.Input,
                Value = strSplit[1]
                };
                myCommand.Parameters.Add(nodeparameter);

This code is also working fine,
but i want to know that which way of writing code is better.
if you have any idea, please tell me.

Thanks