The only thing that I can find is Using, but this does not appear to work in the same way as With....
For example, in VB I can define which object I am working with and then not use the object name again - something like this....
With myObject
.Color = "Red"
.FontSize = "12"
End With
In the above example, I only have to type "myObject" once.
Is this also possible in C#?
Thanks
Gary

VulpesRank #55 · 29.2K reputationPosted Jun 24, 2011, 7:07 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 24, 2011, 4:52 AM EDT
Gary King77 reputationPosted Jun 24, 2011, 5:33 AM EDT
The object in question is a SqlCommand of type StroedProcedure.
What I wanted to do is add all the SP Parameters without having to type the object name for each parameter.
Oh well!!!
VulpesRank #55 · 29.2K reputationPosted Jun 24, 2011, 5:54 AM EDT
var myObject = new SomeType(someArg) { Color = "Red", FontSize = "12" };
Gary King77 reputationPosted Jun 24, 2011, 6:44 AM EDT
Here is the code that I currently have - there are in fact 12 parameters needed for the Stored Proc:
SqlCommand cmdPermitHeader_INSERT = new SqlCommand("p_PermitHeader_INSERT", dbConnPermit);
cmdPermitHeader_INSERT.CommandType = CommandType.StoredProcedure;
cmdPermitHeader_INSERT.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = FirstName.Text;
How would you change that so that I could use:
p.Add("@FirstName", SqlDbType.NVarChar).Value = FirstName.Text;
Gary King77 reputationPosted Jun 24, 2011, 7:14 AM EDT
Ok, not exactly what I was thinking of (along the lines of VB With / End With), but this will do.