CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    154

    a problem - a little confused

    1st I created a struct (class)

    Code:
    namespace RolePlayingGameData
    {
        /// </summary>
        [Serializable]
        public struct SpellList
        {
            //Main guts
            [ContentSerializer(Optional = true)]
            public bool MySpell1;
            [ContentSerializer(Optional = true)]
            public bool MySpell2;
        }
    }
    there is actually a whole bunch more there but I left it out for space reasons

    all of those booleans get written to a xml file, with a true or false setting. But I've drank too much coffee and I forgot how to properly use the for each arguement

    how do I return a updated SpellList with only the Spells marked true in the list??

  2. #2
    Join Date
    Apr 2006
    Posts
    220

    Re: a problem - a little confused

    Do you want something like this...?

    Code:
    SpellList[] list = new SpellList[10];
    ArrayList results = new ArrayList();
    //populated here
    foreach(SpellList listItem in list)
    {
         if(listItem.MySpell1 == true && listItem.MySpell2 == true)
             results.Add(listItem);
    }
    
    //do whatever u wish with results here

  3. #3
    Join Date
    Jun 2008
    Posts
    154

    Re: a problem - a little confused

    Ahh awesome you know I was just thinking that in my head last night (I guess sleeping on it really works!!!) but I didn't know the correct syntax. Ah thanks for pointing that out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured