forum

Home / DeveloperSection / Forums / what is managed way to use a variable's pointer in structure?

what is managed way to use a variable's pointer in structure?

Anonymous User177903-Nov-2014

Hi Guys

i'm trying to write a generic function which should be able to parse a xml file

here is the code

        publicstructXmlArg
        {
            publicstring Name;
            publicType T;
            publicobject Value;
        };
 
        staticbool ParseXmlArgs(XmlReader xml, paramsXmlArg[] args)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                if (xml.MoveToContent() != XmlNodeType.Element || xml.Name != args[i].Name)
                {
                    returnfalse;
                }
                args[i].Value = xml.ReadElementContentAs(args[i].T, null);
            }
            returntrue;
        }
 
        staticvoid Main(string[] args)
        {
            int a = 0;
 
            ParseXmlArgs(
                XmlTextReader.Create("C:\\Users\\Yazilim\\Desktop\\XML.xml"),
                newXmlArg[]{
            newXmlArg() { Name = "ErrorCode", T = typeof(int), Value = a}});
        }

i know that i should pass a's pointer to Value ( it's type should be some different type other than object of course )

but i don't want it to be non-managed way.

is there any managed way to use a variable's pointer in structure ?

Thanks


Updated on 04-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By