I have an object 'connection' which holds the path/credentials to a SQL DB.
When calling methods; we usually do this:
Connection con = new Connection();
GetSalesData(con);
public static void (Connection con)
{
// Run code
}
As I understand, we just created two instance of connection, so that means two memory allocations. Is it better to do this:
Connection con = new Connection();
GetSalesData(ref con);
public static void (ref Connection con)
{
// Run code
}
ref
does not make sense unless you explicitly want to change the value of the passed parameter.public static void (connection con)
makes no sense in any language that I know of. There is noconnection
type, only aConnection
type. Be accurate, Martin.