[Mono-dev] Possible problem with 2.0RC1

Paul paul at all-the-johnsons.co.uk
Wed Sep 17 11:29:43 EDT 2008


Hi,

I have some very simple code which has become unpredictable.

public struct conversion
{
    public bool isverb, isplural;
    public string ddd, ingerman, inenglish, examples, sex;

    public conversion(bool verb, bool plural, string form, string
german, string english, string eg, string gender)
    {
        isplural = plural;
	isverb = verb;
	ddd = form;
        ingerman = german;
        inenglish = english;
	examples = eg;
	sex = gender;
     }
}

List<conversion> words = new List<conversion>();
public int counter;

private void loadfile(string filename)
{
     StreamReader sreader = new
StreamReader(filename,System.Text.Encoding.GetEncoding("iso-8859-15"));
     string line = sreader.ReadLine();
     while (line != null)
     {
         splitline(line);
         counter++;
         line = sreader.ReadLine();
     }
            sreader.Close();
}
		
private string remquotes(string line)
{
     string[] rq = line.Split(new char[] {'"'});
     return rq[1];
}

private void splitline(string line)
{
     string[] stringy = line.Split(new char[] {','});			

     for (int m = 2; m < 6; ++m)
     {
	if (stringy[m] != "")
		stringy[m] = remquotes(stringy[m]);
     }
			
	// 1st column = plural (1 = yes) set as true if correct
	// 2nd column = verb   (1 = yes) set as true if correct
			
        words.Add(new conversion((stringy[0] == "1" ? true : false),
        	                 (stringy[1] == "1" ? true : false),
        	                 stringy[2], stringy[3], stringy[4],
			         stringy[5], stringy[6]));
			
	if (stringy[1] == "1")
	{
		Console.WriteLine("word {0}, is a verb", stringy[3]);
	}
} 

The file read in is a CSV file with the following format

A	B	C	D	E	F	G
0/1	0/1	der	german	english	example	gender

If A = 1, it's a plural
If B = 1, it's a verb.

The problem seems to come from the words.Add method in that the
stringy[0] == "1" ? true : false test does not always yield the correct
answer - I've had plurals come out as singles and nouns come out as
verbs.

Can someone tell me if this is me being a twit or if mono is being
silly? I'm using RC1 on Fedora. Source and test file available if you
want to test them.

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: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080917/4a4580dd/attachment-0001.bin 


More information about the Mono-devel-list mailing list