views:

64

answers:

1

I've seen someone use a Sys.StringBuilder in asp.net ajax, is it possible to use generics as well? I essentially have a List of comment objects (That contains a datetime, a string (Title), and another string (content)) and am trying to work out the best way to handle the data when it is returned to the javascript from a web service. Am I going to have to do something like an array of arrays and push all the list data into there?

A: 

Yes you can use generics in your asp.net code but if you use it you must consider that your generic list will have always the same type objects.

So you could do:

    const int CAPACITY = 10;

    List<String>[] a_l = new List<String>[CAPACITY];

    (a_l[0] = new List<string>()).Add(DateTime.Now.ToString());
    (a_l[1] = new List<string>()).Add("Title");
     ...
     ...

After you could parse your list and build a JSON object to pass back to your JS code...

xdevel2000
Awesome, thanks
Jack Mills