Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

By calling GetLatestDatabaseIteration(TEST_MANAGEMENTEntities managementEntity) you are not passing an object of type TEST_MANAGEMENTEntities to the method but a reference of that object to the method.

See: http://stackoverflow.com/a/8708674/2655508 https://stackoverflow.com/a/8708674/2655508

Objects aren't passed at all. By default, the argument is evaluated and its value is passed, by value, as the initial value of the parameter of the method you're calling. Now the important point is that the value is a reference for reference types - a way of getting to an object (or null). Changes to that object will be visible from the caller. However, changing the value of the parameter to refer to a different object will not be visible when you're using pass by value, which is the default for all types.

If you want to use pass-by-reference, you must use out or ref, whether the parameter type is a value type or a reference type. In that case, effectively the variable itself is passed by reference, so the parameter uses the same storage location as the argument - and changes to the parameter itself are seen by the caller.

So by calling tm_entity.Dispose(); you are basically disposing the original object.

private static void foo()
{
 TEST_MANAGEMENTEntities theEntity = new TEST_MANAGEMENTEntities();
 int latestID = GetLatestDatabaseIteration(theEntity);
 // now theEntity is already disposed
}

If this is what you wanted to do, then it isn't the right place. A consumer/caller of this method would not expect that the passed in "object" whould be disposed after returning.

If you are working with IDisposable objects you should use using blocks.

Naming

In addition to Nick Udell's answer please see the naming guidelines .

By calling GetLatestDatabaseIteration(TEST_MANAGEMENTEntities managementEntity) you are not passing an object of type TEST_MANAGEMENTEntities to the method but a reference of that object to the method.

See: http://stackoverflow.com/a/8708674/2655508

Objects aren't passed at all. By default, the argument is evaluated and its value is passed, by value, as the initial value of the parameter of the method you're calling. Now the important point is that the value is a reference for reference types - a way of getting to an object (or null). Changes to that object will be visible from the caller. However, changing the value of the parameter to refer to a different object will not be visible when you're using pass by value, which is the default for all types.

If you want to use pass-by-reference, you must use out or ref, whether the parameter type is a value type or a reference type. In that case, effectively the variable itself is passed by reference, so the parameter uses the same storage location as the argument - and changes to the parameter itself are seen by the caller.

So by calling tm_entity.Dispose(); you are basically disposing the original object.

private static void foo()
{
 TEST_MANAGEMENTEntities theEntity = new TEST_MANAGEMENTEntities();
 int latestID = GetLatestDatabaseIteration(theEntity);
 // now theEntity is already disposed
}

If this is what you wanted to do, then it isn't the right place. A consumer/caller of this method would not expect that the passed in "object" whould be disposed after returning.

If you are working with IDisposable objects you should use using blocks.

Naming

In addition to Nick Udell's answer please see the naming guidelines .

By calling GetLatestDatabaseIteration(TEST_MANAGEMENTEntities managementEntity) you are not passing an object of type TEST_MANAGEMENTEntities to the method but a reference of that object to the method.

See: https://stackoverflow.com/a/8708674/2655508

Objects aren't passed at all. By default, the argument is evaluated and its value is passed, by value, as the initial value of the parameter of the method you're calling. Now the important point is that the value is a reference for reference types - a way of getting to an object (or null). Changes to that object will be visible from the caller. However, changing the value of the parameter to refer to a different object will not be visible when you're using pass by value, which is the default for all types.

If you want to use pass-by-reference, you must use out or ref, whether the parameter type is a value type or a reference type. In that case, effectively the variable itself is passed by reference, so the parameter uses the same storage location as the argument - and changes to the parameter itself are seen by the caller.

So by calling tm_entity.Dispose(); you are basically disposing the original object.

private static void foo()
{
 TEST_MANAGEMENTEntities theEntity = new TEST_MANAGEMENTEntities();
 int latestID = GetLatestDatabaseIteration(theEntity);
 // now theEntity is already disposed
}

If this is what you wanted to do, then it isn't the right place. A consumer/caller of this method would not expect that the passed in "object" whould be disposed after returning.

If you are working with IDisposable objects you should use using blocks.

Naming

In addition to Nick Udell's answer please see the naming guidelines .

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

By calling GetLatestDatabaseIteration(TEST_MANAGEMENTEntities managementEntity) you are not passing an object of type TEST_MANAGEMENTEntities to the method but a reference of that object to the method.

See: http://stackoverflow.com/a/8708674/2655508

Objects aren't passed at all. By default, the argument is evaluated and its value is passed, by value, as the initial value of the parameter of the method you're calling. Now the important point is that the value is a reference for reference types - a way of getting to an object (or null). Changes to that object will be visible from the caller. However, changing the value of the parameter to refer to a different object will not be visible when you're using pass by value, which is the default for all types.

If you want to use pass-by-reference, you must use out or ref, whether the parameter type is a value type or a reference type. In that case, effectively the variable itself is passed by reference, so the parameter uses the same storage location as the argument - and changes to the parameter itself are seen by the caller.

So by calling tm_entity.Dispose(); you are basically disposing the original object.

private static void foo()
{
 TEST_MANAGEMENTEntities theEntity = new TEST_MANAGEMENTEntities();
 int latestID = GetLatestDatabaseIteration(theEntity);
 // now theEntity is already disposed
}

If this is what you wanted to do, then it isn't the right place. A consumer/caller of this method would not expect that the passed in "object" whould be disposed after returning.

If you are working with IDisposable objects you should use using blocks.

Naming

In addition to Nick Udell's answer answer please see the naming guidelines .

By calling GetLatestDatabaseIteration(TEST_MANAGEMENTEntities managementEntity) you are not passing an object of type TEST_MANAGEMENTEntities to the method but a reference of that object to the method.

See: http://stackoverflow.com/a/8708674/2655508

Objects aren't passed at all. By default, the argument is evaluated and its value is passed, by value, as the initial value of the parameter of the method you're calling. Now the important point is that the value is a reference for reference types - a way of getting to an object (or null). Changes to that object will be visible from the caller. However, changing the value of the parameter to refer to a different object will not be visible when you're using pass by value, which is the default for all types.

If you want to use pass-by-reference, you must use out or ref, whether the parameter type is a value type or a reference type. In that case, effectively the variable itself is passed by reference, so the parameter uses the same storage location as the argument - and changes to the parameter itself are seen by the caller.

So by calling tm_entity.Dispose(); you are basically disposing the original object.

private static void foo()
{
 TEST_MANAGEMENTEntities theEntity = new TEST_MANAGEMENTEntities();
 int latestID = GetLatestDatabaseIteration(theEntity);
 // now theEntity is already disposed
}

If this is what you wanted to do, then it isn't the right place. A consumer/caller of this method would not expect that the passed in "object" whould be disposed after returning.

If you are working with IDisposable objects you should use using blocks.

Naming

In addition to Nick Udell's answer please see the naming guidelines .

By calling GetLatestDatabaseIteration(TEST_MANAGEMENTEntities managementEntity) you are not passing an object of type TEST_MANAGEMENTEntities to the method but a reference of that object to the method.

See: http://stackoverflow.com/a/8708674/2655508

Objects aren't passed at all. By default, the argument is evaluated and its value is passed, by value, as the initial value of the parameter of the method you're calling. Now the important point is that the value is a reference for reference types - a way of getting to an object (or null). Changes to that object will be visible from the caller. However, changing the value of the parameter to refer to a different object will not be visible when you're using pass by value, which is the default for all types.

If you want to use pass-by-reference, you must use out or ref, whether the parameter type is a value type or a reference type. In that case, effectively the variable itself is passed by reference, so the parameter uses the same storage location as the argument - and changes to the parameter itself are seen by the caller.

So by calling tm_entity.Dispose(); you are basically disposing the original object.

private static void foo()
{
 TEST_MANAGEMENTEntities theEntity = new TEST_MANAGEMENTEntities();
 int latestID = GetLatestDatabaseIteration(theEntity);
 // now theEntity is already disposed
}

If this is what you wanted to do, then it isn't the right place. A consumer/caller of this method would not expect that the passed in "object" whould be disposed after returning.

If you are working with IDisposable objects you should use using blocks.

Naming

In addition to Nick Udell's answer please see the naming guidelines .

Source Link
Heslacher
  • 50.9k
  • 5
  • 83
  • 177

By calling GetLatestDatabaseIteration(TEST_MANAGEMENTEntities managementEntity) you are not passing an object of type TEST_MANAGEMENTEntities to the method but a reference of that object to the method.

See: http://stackoverflow.com/a/8708674/2655508

Objects aren't passed at all. By default, the argument is evaluated and its value is passed, by value, as the initial value of the parameter of the method you're calling. Now the important point is that the value is a reference for reference types - a way of getting to an object (or null). Changes to that object will be visible from the caller. However, changing the value of the parameter to refer to a different object will not be visible when you're using pass by value, which is the default for all types.

If you want to use pass-by-reference, you must use out or ref, whether the parameter type is a value type or a reference type. In that case, effectively the variable itself is passed by reference, so the parameter uses the same storage location as the argument - and changes to the parameter itself are seen by the caller.

So by calling tm_entity.Dispose(); you are basically disposing the original object.

private static void foo()
{
 TEST_MANAGEMENTEntities theEntity = new TEST_MANAGEMENTEntities();
 int latestID = GetLatestDatabaseIteration(theEntity);
 // now theEntity is already disposed
}

If this is what you wanted to do, then it isn't the right place. A consumer/caller of this method would not expect that the passed in "object" whould be disposed after returning.

If you are working with IDisposable objects you should use using blocks.

Naming

In addition to Nick Udell's answer please see the naming guidelines .

lang-cs

AltStyle によって変換されたページ (->オリジナル) /