I have a class with two constructors (C #). Here is the code snippet:
public class FooBar() { public FooBar(string s) {
Yes, I know that I can name one constructor from another using the above approach. But in this case, if I call constructor 2, all instructions in constructor 1 will be executed BEFORE the statement itself is executed in constructor 2.
I want that after all the statements in constructor 2 are executed, it is called by constructor 1.
In my exact situation, I am performing user authentication. Constructor 1 retrieves user information with only the user ID, but constructor 2 authenticates the user using email and password. If the user is in the database, he gets the user ID, and now I want constructor 1 to populate all the properties of the class.
Please let me know if you need more information. If you think there is another better approach, I would be glad to hear the suggestion.
UPDATE 1: I wonder why something like this is not implemented:
public FooBar(bool b) {
Farhan
source share