How to get and set config in Drupal 8

Drupal 8 provides configuration manager module which helps in managing configuration across the various environment of the same website, the configuration can be fetched and altered in a custom module in following way. 

//Fetching Site Name using configuration.
$site_name = \Drupal::config('')->get('name');
//To edit configuration as well use getEditable method.
$config = \Drupal::service('config.factory')->getEditable('');
// Setting DrupalABC as Sitename.
$config->set('name', 'DrupalABC')->save();