1

Hi all here comes a noob question,

i am trying around with twitter library "linq2twitter" in C#. I would like to get the content from :

System.Collections.Generic.List <.LinqToTwitter.MediaEntity.>

My attempt is simple:

public string[] MediaContent;

MediaContent = tweet.Entities.MediaEntities.ToArray()

I tried to convert it into an string[] array with the .ToArray() function but i am getting an the error "conversion from Type LinqToTwitter.MediaEntity[] in string[] is not possible"

I guess there is a better way to get the data from this Type of List ? Can someone give me a tip?

thx,

Fid

fid200
  • 47
  • 3
  • 1
    MediaEntity is a class. You will need to explicitly convert this. Probably by doing some thing like: tweet.Entities.MediaEntities.Select(me => me.PropertyYouWantThatIsAString).ToArray() – thorkia Mar 31 '15 at 14:54

1 Answers1

1

You could use the technique in thorkia's comment to obtain one of the string properties of MediaEntity, but it's not clear that's what you want. Here's how to convert the List to a MediaEntity[]:

public MediaEntity[] MediaContent;

MediaContent = tweet.Entities.MediaEntities.ToArray()

Here, all I did was change the array type from string[] to MediaEntity[].

Joe Mayo
  • 7,501
  • 7
  • 41
  • 60
  • Thanks Joe (also for your great library) and also thx to thorkia, that was very helpful ;-) – fid200 Mar 31 '15 at 16:38