Drupal 8 variable_get I have some code in Drupal 7 what are using variable_get. Now I would like to write the code in Drupal 8. So I was reading this but its didn't help me a lot.

How to write this code in Drupal 8 from code in Drupal 7?

$types = array_values(variable_get('test_content_types', array()));


or this

'#default_value' =&gt; variable_get('test_content_types', array()),


Some suggestion.
In Drupal 7

 $data =  variable_get('test_content_types');


In Drupal 8

 $data = \Drupal::state()-&gt;get('test_content_types'); 


For more information about about "get", "set", "delete" visit - Step 5: How to upgrade D7 variables to D8's state system.