Tommy Sin

Tommy Sin

  • NA
  • 19
  • 103.5k

Regarding the question about the function and enum.

Apr 5 2011 2:02 PM
Hello.
       
The source code is below. And Then, what is the purpose of enum in the parameter in this case although it doesnt have any usage?


Here is the source code.


public enum SilentLoud
{
        Silent = -1,
        Loud = 0
}

public bool Close()
{
        return Close(SilentLoud.Loud);        
}

public bool Close(SilentLoud silent)
{
        if(!_initialised)
                return false;
        if(!IsConnected)
                return false;
        
        _client.Close();
        return true;
}



Then, I am just wondering why Close Function is split into 2 functions in this case. Can we not merge the two functions in to one like this?

public bool Close()
{
        if(!_initialised)
                return false;
        if(!IsConnected)
                return false;
        
        _client.Close();
        return true;
}



Answers (1)