Q:

Passing a string in a method that takes a method as its parameter

I have a method in a class called SqlInteraction:
public static string sqlQueryReturnString(Func<SqlConnection, string> sqlMethod)
{
    string result = "";
    SqlConnection conn = new SqlConnection();
    conn.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
    try
    {
        //open SQL connection
        conn.Open();
        result = sqlMethod(conn);
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.Write(ex.ToString());
    }
    finally
    {
        conn.Close();
    }
    return result;
}

Here is another method in a different class that uses it:
private string getPKofUserLoggedIn(SqlConnection conn, string PointPerson)
{
    int result = 0;
    SqlCommand getPKofUserLoggedIn = new SqlCommand("SELECT [PK_User] FROM [User] WHERE [LoginName] = @userIdParam", conn);
    //create and assign parameters
    getPKofUserLoggedIn.Parameters.AddWithValue("@userIdParam", PointPerson);
    //execute command and retrieve primary key from the above insert and assign to variable
    result = (int)getPKofUserLoggedIn.ExecuteScalar();
    return result.ToString();
}

I am having trouble passing the string in the second method. If I remove 'string PointPerson' this call works:
SqlInteraction.sqlQueryReturnString(getPKofUserLoggedIn);

How do I pass the string as well?

A:

Func<SqlConnection, string> reads as 'a function that takes a SqlConnection parameter and returns a string' - which, if you remove PointPerson then you have.
If you want to add a parameter from an outer method, you can do the following:
var myParam = "some string";
SqlInteraction.sqlQueryReturnString(conn => getPKofUserLoggedIn(conn, myParam));

