out-parameters

Using TryGetValue() in LINQ?

This code works, but is inefficient because it double-lookups the ignored dictionary. How can I use the dictionary TryGetValue() method in the LINQ statement to make it more efficient? IDictionary<int, DateTime> records = ... IDictionary<int, ISet<DateTime>> ignored = ... var result = from r in records where !ignored.Cont...

C#: can 'out' parameters in functions be object properties/variables?

C#: can 'out' parameters in functions be object properties/variables? eg: can I call a function as follows: someFunction(x, y, out myObject.MyProperty1) ...

why can't I pass an unassigned object variable in an out parameter and then assign it

In C#, why can't I pass an unassigned object variable in an out parameter and then assign it? If I try to do this, there is a compiler error: "Local variable <xyz> cannot be declared in this scope because it would give a different meaning to <xyz>..." eg. void MyMethod(int x, out MyObject mo) { **MyObject** mo = new MyObject(); } // ...

MySql, .NET, Stored Procedures sharing the current date and time with the calling client

I'm writing a stored procedure to update a table: UPDATE st SET somedate = NOW(); The client of the SP must know the exact date and time generated by the NOW function. There are two options: 1) the client passes an input parameter (called _now) to the SP giving it the current date and time UPDATE st SET somedate = _now; 2) the S...

.NET LINQ Call Method with Out Parameters Within Query and use Out Values

Hi All I have a list of objects, which has a method that has a couple of out parameters. How do i call this method on each object, get the out parameter values and use them later on in the query, perhaps for checking in a where clause? Is this possible and if so can someone please demonostrate through sample code. Thanks! ...

Problem reading out parameter from stored procedure using c#

Hi, I just come across a strange problem where i cannot retrieve the sql stored procedure out parameter value. I struck with this problem for nearly 2 hours. Code is very simple using (var con = new SqlConnection(connectionString)) { con.Open(); SqlCommand cmd = new SqlCommand("sp_mgsearach", con); ...

C# - how to pass 'out' parameter into lambda expression

I have a method with the following signature: private PropertyInfo getPropertyForDBField(string dbField, out string prettyName) In it, I find the associated value prettyName based on the given dbField. I then want to find all properties, if any, that have the name prettyName, so I'm trying to do the following: IEnumerable<PropertyIn...