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

Paul paul at all-the-johnsons.co.uk
Tue Apr 3 17:52:48 EDT 2007


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!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20070403/25474e84/attachment.bin 


More information about the Mono-list mailing list