title: Android App - Xamarin - C# - How to return multiple integer variable values back to main activity?
body: <p>I am trying to return multiple integer variable values from a second activity to the main activity, In the second activity I have a number of variables which are calculated through different functions which I need to return to the main activity to be added onto the total of another variable.</p>
  
  <p>In my main activity I have started the second activity using StartActivityForResult</p>
  
  <pre><code>FindViewById&lt;Button&gt;(Resource.Id.btnAddItems).Click += delegate
          {
              var getMoreItems = new Intent (this, typeof(Activity2));
              StartActivityForResult(getMoreItems,0);
          };  
  </code></pre>
  
  <p>In the second activity I am attempting to return the values using PutExtra and an Intent, there are 7 integer variables and one string I am trying to return.</p>
  
  <pre><code>        FindViewById&lt;Button&gt;(Resource.Id.btnReturnItems).Click += delegate
          {
              Intent returnItems = new Intent(this, typeof(MainActivity));
              string addOrSub = "add";
              returnItems.PutExtra("putAddOrSub", addOrSub);
              returnItems.PutExtra("putVar1", int1);
              returnItems.PutExtra("putVar2", int2);
              returnItems.PutExtra("putVar3", int3);
              returnItems.PutExtra("putVar4", int4);
              returnItems.PutExtra("putVar5", int5);
              returnItems.PutExtra("putVar6", int6);
              returnItems.PutExtra("putVar7", int7);
              SetResult(Result.Ok, returnItems);
              Finish();
          };
  </code></pre>
  
  <p>Im not entirely sure, but I think my problem lies within my OnActivityResult override back on my main activity.  First of all I tried</p>
  
  <pre><code>protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
          {
              base.OnActivityResult(requestCode, resultCode, data);
              if (resultCode == Result.Ok)
              {
                  string addOrSub = data.GetStringExtra("putAddOrSub");
                  if (addOrSub == "add")
                  {
                      int tmpInt1 = data.GetIntExtra("putVar1");
                      int tmpInt2 = data.GetIntExtra("putVar2");
                      int tmpInt3 = data.GetIntExtra("putVar3");
                      int tmpInt4 = data.GetIntExtra("putVar4");
                      int tmpInt5 = data.GetIntExtra("putVar5");
                      int tmpInt6 = data.GetIntExtra("putVar6");
                      int tmpInt7 = data.GetIntExtra("putVar7");
                      updInt1 += tmpInt1;
                      updInt2 += tmpInt2;
                      updInt3 += tmpInt3;
                      updInt4 += tmpInt4;
                      updInt5 += tmpInt5;
                      updInt6 += tmpInt6;
                      updInt7 += tmpInt7;
                      anotherFunction();
  
                  }
              }
          }
  </code></pre>
  
  <p>I was unable to run that because I recieved the error </p>
  
  <p>"There is no argument given that corresponds to the required formal parameter 'defaultValue' of 'Intent.GetIntExtra(string, int)'"</p>
  
  <p>I decided to try adding a Convert.ToInt32 and changed to a GetStringExtra command, because I assume it for some reason is returning the data as a string.</p>
  
  <pre><code>protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
          {
              base.OnActivityResult(requestCode, resultCode, data);
              if (resultCode == Result.Ok)
              {
                  string addOrSub = data.GetStringExtra("putAddOrSub");
                  if (addOrSub == "add")
                  {
                      int tmpInt1 = Convert.ToInt32(data.GetStringExtra("putVar1"));
                      int tmpInt2 = Convert.ToInt32(data.GetStringExtra("putVar2"));
                      int tmpInt3 = Convert.ToInt32(data.GetStringExtra("putVar3"));
                      int tmpInt4 = Convert.ToInt32(data.GetStringExtra("putVar4"));
                      int tmpInt5 = Convert.ToInt32(data.GetStringExtra("putVar5"));
                      int tmpInt6 = Convert.ToInt32(data.GetStringExtra("putVar6"));
                      int tmpInt7 = Convert.ToInt32(data.GetStringExtra("putVar7"));
                      updInt1 += tmpInt1;
                      updInt2 += tmpInt2;
                      updInt3 += tmpInt3;
                      updInt4 += tmpInt4;
                      updInt5 += tmpInt5;
                      updInt6 += tmpInt6;
                      updInt7 += tmpInt7;
                      anotherFunction();
  
                  }
              }
          }
  </code></pre>
  
  <p>Now I can run this in the Android Emulator, but it seems that there are no values being returned and for the life of me I cannot figure out why.</p>
  
  <p>Please help!!
  Excuse my noobyness, this is my first attempt at an android app and I've been struggling with this problem for the last 5 hours.</p>