[Mono-list] Creating a list generic of a struct

Alan McGovern alan.mcgovern at gmail.com
Tue Apr 3 18:11:46 EDT 2007


(sorry, meant to send to the list)

Shouldnt the line be:

words.Add(new Conversion((stringy[0] == "0" ? false : true),
                                        (stringy[1] == "0" ? false : true),
                                         stringy[2], stringy[3]));

You can't add "bool bool string string" to your word array as it's expecting
your struct to be there.

Alan.


On 4/3/07, Paul <paul at all-the-johnsons.co.uk> wrote:
>
> Hi,
>
> Code snippet to start with...
>
> namespace foo
> {
>   class doitall
>   {
>      public struct conversion
>      {
>         public bool isverb, isplural;
>         public string foreign, english;
>
>         public conversion(bool verb, bool plural, string noneng, string
> eng)
>         {
>            Console.WriteLine("{0} = {1} = {2} = {3}\n", verb, plural,
> noneng, eng);
>            this.isverb = verb;
>            this.isplural = plural;
>            this.foreign = noneng;
>            this.english = eng;
>         }
>      }
>
>      List <conversion> words;
>
>      // stuff
>
>      private void splitline(string line)
>      {
>         string[] stringy = line.Split(new char[] {','});
>         stringy[2] = removequotes(stringy[2]); // removes quote marks
>         stringy[3] = removequotes(stringy[3]);
>         words.Add((stringy[0] == "0" ? false : true),
>                   (stringy[1] == "0" ? false : true),
>                   stringy[2], stringy[3]);
>      }
>
>      public static void Main()
>      {
>         string filename = "Topic A.csv";
>         List<conversion> words = new List<conversion>();
>         doitall dia = new doitall();
>         dia.loadfilename(filename);
>      }
>   }
> }
>
> The problem is in the splitline when the words.Add is called as there is
> no method to add 4 arguments. Is there a way to add and read from the
> struct when using the struct? Do I just need to add a couple of get/sets
> to the struct?
>
> TTFN
>
> Paul
> --
> Sie können mich aufreizen und wirklich heiß machen!
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070403/60a6e304/attachment.html 


More information about the Mono-list mailing list