I have a little code
public void StartConnection(){
_connection = new DatabaseConnection();
}
public Results ExecuteQuery( string format ){
_queryExecuter.SetText = string.Format(_queryString, format);
return _queryExecuter.Execute();
}
What I did, it allowed to use private members inside public methods ?
I mention that public methods will be used in another classes (from different project but in same solution).
Or I have to create private methods and use inside the private variables ?
I need just advices.
Thank you
Yes its a very fundamental programming philosophy called encapsulation. Its perfectly valid and encouraged to do so. In your case, only you know how to use your connection object and “restrict” how to use it via your public method, thus keeping your application in your defined bounds.