0

I'm a beginner C# developer, actually, i'm coding a game. My question is about load an XML from my windows phone app.

I have a list of object that I'd like to fill with my xml's element. But the problem is that I can't serialize more than one Element. I'd like to store data (image's position) in my list.

Maybe my code will help you better understand what I mean

[XmlRoot("root")]
public class Map
{
    [XmlElement]
    public int IdTexture { get; set; }
    [XmlArray(ElementName = "Buildings")]
    [XmlArrayItem(ElementName = "Building")]
    public List<Buildings> Build_list { get; set; } 
    [XmlArray(ElementName = "Trees")]
    [XmlArrayItem(ElementName = "Tree")] 
    public List<Trees> Trees_list { get; set; }
    [XmlArray(ElementName = "Rocks")]
    [XmlArrayItem(ElementName = "Rock")]
    public List<Rock> Rock_list { get; set; }
    [XmlArray(ElementName = "Roads")]
    [XmlArrayItem(ElementName = "Road")]
    public List<Road> Road_list { get; set; }
    //[XmlElement]
    [XmlArray(ElementName = "Bornes")]
    [XmlArrayItem(ElementName = "Borne")]
    public List<Bornes> Bornes_list { get; set; }


    public void Map()
    {
        Build_list = new List<Buildings>();
        Trees_list = new List<Trees>();
        Rock_list = new List<Rock>();
        Road_list = new List<Road>();
        Bornes_list = new List<Bornes>();
     }

what should I use?


having a powers of 2 questions

    import acm.program.*;

    public class Practice3 extends ConsoleProgram
    {
        public static int powersOf2(int k) {
        int x = 0;
        while (k < 1000) {
            x = k;
            k *= 2;
        }
        return x;   
    }

    public void run()
    {
        println(powersOf2(1));
        println(powersOf2(0));
        println(powersOf2(2));
        println(powersOf2(-1));
        println(powersOf2(3000));
    }

I don't think I really get right values from powersOf2. Only 512 is displayed when I run program. And if I run it by each println, it gives me:

512
none
512
none
0

Is there something wrong? or values are correct?

4

0 回答 0