title: Xamarin, translating Java to C#: Bundle does not exist in current context
body: <p>I'm trying to convert a small self-made app from Java code to C#.</p>
  
  <p>Now I'm trying to figure out why I keep getting <code>The name 'savedInstanceState' does not exist in the current context</code>.
  You'll find <code>savedInstanceState</code> in the first method:</p>
  
  <pre><code>using System;
  using Android.App;
  using Android.Content;
  using Android.Widget;
  using System.Collections.Generic;
  using Android.Runtime;
  using Android.Content.PM;
  using Java.Util;
  using Android.OS;
  using System.Linq;
  using AkvaC;
  
  using System;
  using System.Collections;
  using System.Collections.Generic;
  using Android.App;
  using Android.Content;
  using Android.Content.PM;
  using Android.OS;
  using Android.Runtime;
  using Android.Views;
  using Android.Widget;
  using Java.Util;
  using Xamarin.ActionbarSherlockBinding.App;
  using Xamarin.ActionbarSherlockBinding.Views;
  using IMenu = Xamarin.ActionbarSherlockBinding.Views.IMenu;
  using IMenuItem = Xamarin.ActionbarSherlockBinding.Views.IMenuItem;
  using MenuItem = Xamarin.ActionbarSherlockBinding.Views.MenuItem;
  using ISubMenu = Xamarin.ActionbarSherlockBinding.Views.ISubMenu;
  
  namespace AkvaC
  {
      public class Support13Demos : ListActivity {
  
          Bundle savedInstanceState;
  
          public override void onCreate(Bundle savedInstanceState) {
              base.OnCreate(savedInstanceState);
  
              Intent intent = Intent();
              String path = intent.GetStringExtra("com.Pynting.Akvaapp.Apis.Path");
  
              if (path == null) {
                  path = "";
              }
  
              ListAdapter = new SimpleAdapter (this, GetData (path),
                  Android.Resource.Layout.SimpleListItem1, new String[] { "title" },
                  new int[] { Android.Resource.Id.Text1 });
              ListView.TextFilterEnabled = true;
          }
  
          protected IList&lt;IDictionary&lt;string,object&gt;&gt; GetData (string prefix)
          {
              List&lt;IDictionary&lt;string, Object&gt;&gt; myData = new List&lt;IDictionary&lt;string, Object&gt;&gt;();
  
              Intent mainIntent = new Intent(Intent.ActionMain, null);
              mainIntent.AddCategory("com.Pynting.Akvaapp.SUPPORT13_SAMPLE_CODE");
  
              PackageManager pm = PackageManager();
  
              var list = pm.QueryIntentActivities (mainIntent, 0);
  
              if (null == list)
                  return myData;
  
              String[] prefixPath;
              String prefixWithSlash = prefix;
  
              if (prefix == "") {
                  prefixPath = null;
              } else {
                  prefixPath = prefix.Split ('/');
                  prefixWithSlash = prefix + "/";
              }
  
              int len = list.Count();
  
              Dictionary&lt;String, Boolean&gt; entries = new Dictionary&lt;String, Boolean&gt;();
  
              for (int i = 0; i &lt; len; i++) {
                  ResolveInfo info = list [i];
                  var labelSeq = info.LoadLabel (pm);
                  String label = labelSeq != null
                      ? labelSeq.ToString ()
                      : info.ActivityInfo.Name;
                  if (prefixWithSlash.Length == 0 || label.StartsWith (prefixWithSlash)) {
                      String[] labelPath = label.Split ('/');
                      String nextLabel = prefixPath == null ? labelPath [0] : labelPath [prefixPath.Length];
                      if ((prefixPath != null ? prefixPath.Length : 0) == labelPath.Length - 1) {
                          AddItem (myData, nextLabel, ActivityIntent (
                              info.ActivityInfo.ApplicationInfo.PackageName,
                              info.ActivityInfo.Name));
                      } else {
                          if (entries.ContainsKey (nextLabel)) {
                              AddItem (myData, nextLabel, BrowseIntent (prefix == "" ? nextLabel : prefix + "/" + nextLabel));
                              entries [nextLabel] = true;
                          }
                      }
                  }
              }
  
              myData.Sort (sDisplayNameComparator);
  
              return myData;
          }
  
          private readonly static Comparison&lt;IDictionary&lt;string, object&gt;&gt; sDisplayNameComparator = (map1, map2) =&gt; {
              return string.Compare (ToString (map1 ["title"]), ToString (map2 ["title"]));
          };
  
          static string ToString (Object obj)
          {
              return obj != null ? obj.ToString () : null;
          }
  
          protected Intent ActivityIntent (string pkg, string componentName)
          {
              Intent result = new Intent ();
              result.SetClassName (pkg, componentName);
              return result;
          }
          protected Intent BrowseIntent (string path)
          {
              Intent result = new Intent ();
              result.SetClass (this, typeof(SampleList));
              result.PutExtra ("com.example.android.apis.Path", path);
              return result;
          }
          protected void AddItem (IList&lt;IDictionary&lt;String, Object&gt;&gt; data, string name, Intent intent)
          {
              var temp = new JavaDictionary&lt;string, Object&gt; ();
              temp ["title"] = name;
              temp ["intent"] = intent;
              data.Add (temp);
          }
          // @SuppressWarnings("unchecked")
          protected override void OnListItemClick (ListView l, View v, int position, long id)
          {
              var map = (IDictionary&lt;String, Object&gt;)l.GetItemAtPosition (position);
              Intent intent = (Intent)map ["intent"];
              StartActivity (intent);
          }
  }
  </code></pre>
  
  <p>How do I make it work?</p>