-1

How to write this in C#?

Intent intent = new Intent(Intent.ActionSendMultiple, Android.Provider.MediaStore.Images.Media.ExternalContentUri);
handler(intent);            

....

void handler(Intent intent)
{
    ArrayList<Uri> imageUris = intent.GetParcelableArrayListExtra(Intent.ExtraStream);

    ...
}
xanatos
  • 109,618
  • 12
  • 197
  • 280
Calvin89
  • 194
  • 1
  • 4
  • 15
  • 2
    `ArrayList` is still avaiable in C# but it belongs on old days when C# doesn't have _generics_. Use `List` instead. – Soner Gönül Sep 11 '13 at 08:51
  • It returns IList, read documentation http://docs.go-mono.com/index.aspx?link=M%3AAndroid.Content.Intent.GetIntegerArrayListExtra(System.String) – Ilya Ivanov Sep 11 '13 at 08:51
  • I'm sure you're not actually going to ask questions as you progress line by line. Short answer: Use the `List` class (which is not an interface in the C# BCL as opposed to Java's). Long answer: please read the rules of this site... Better answer: I'm sure there exist Java 2 C# translators which work empirically of course, but they could give you a hand. Look at this question: http://stackoverflow.com/questions/443010/where-can-i-find-a-java-to-c-sharp-converter – Eduard Dumitru Sep 11 '13 at 08:54
  • I edited my question, I want it to match the Intent for Android. But the code is written in Java, so now I want to change it to C# – Calvin89 Sep 11 '13 at 09:01

2 Answers2

3

ArrayList is available is c# but it does not have a generic (<T>) form. ArrayList is a list of objects.

What you want is System.Collections.Generic.List<T>

EDIT : In response to comments, try this;

List<Uri> imageUris = new List<Uri>(intent.GetIntegerArrayListExtra(Intent.ExtraStream));
Gusdor
  • 14,001
  • 2
  • 52
  • 64
1

Easy, just use List<Uri>. It's also faster than ArrayList.

weiglt
  • 1,059
  • 8
  • 15