PC Review


Reply
Thread Tools Rate Thread

Casting and iteration in object of type object

 
 
eliassal
Guest
Posts: n/a
 
      6th Jan 2010
Hi I have a function in a dll that returns an object which I need to get
somes items as follows

public object[] CreateFacts(RuleSetInfo ruleSetInfo)
{
XmlDocument doc = new XmlDocument();
//Loading the XML from xml file to be tested against rule.
doc.Load(@_xmlDocToBeused);
TypedXmlDocument txd = new TypedXmlDocument(_DocType, doc);

//Preeapre facts object
object[] facts = new object[1];
facts[0] = txd;

return facts;
}


In my app, I neeed to retrieve this 1st item, I am trying the following

object fact = fc.CreateFacts(RSSetInfo);

I need something like that

TypedXmlDocument test = fact[0];
but geting error indicating that "CAN NOT APPLY INDEXING WITH [0] to an
expression of type object

I tried several casting but it is not working

Thanks for your help
 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      7th Jan 2010
On 1/6/2010 5:13 PM, eliassal wrote:
> Hi I have a function in a dll that returns an object which I need to get
> somes items as follows
>
> public object[] CreateFacts(RuleSetInfo ruleSetInfo)
> {
> XmlDocument doc = new XmlDocument();
> //Loading the XML from xml file to be tested against rule.
> doc.Load(@_xmlDocToBeused);
> TypedXmlDocument txd = new TypedXmlDocument(_DocType, doc);
>
> //Preeapre facts object
> object[] facts = new object[1];
> facts[0] = txd;
>
> return facts;
> }
>
>
> In my app, I neeed to retrieve this 1st item, I am trying the following
>
> object fact = fc.CreateFacts(RSSetInfo);
>
> I need something like that
>
> TypedXmlDocument test = fact[0];
> but geting error indicating that "CAN NOT APPLY INDEXING WITH [0] to an
> expression of type object
>
> I tried several casting but it is not working
>
> Thanks for your help


Try:

object [] fact = fc.CreateFacts(RSSetInfo);

--
Mike
 
Reply With Quote
 
eliassal
Guest
Posts: n/a
 
      8th Jan 2010
Thanks

"Family Tree Mike" wrote:

> On 1/6/2010 5:13 PM, eliassal wrote:
> > Hi I have a function in a dll that returns an object which I need to get
> > somes items as follows
> >
> > public object[] CreateFacts(RuleSetInfo ruleSetInfo)
> > {
> > XmlDocument doc = new XmlDocument();
> > //Loading the XML from xml file to be tested against rule.
> > doc.Load(@_xmlDocToBeused);
> > TypedXmlDocument txd = new TypedXmlDocument(_DocType, doc);
> >
> > //Preeapre facts object
> > object[] facts = new object[1];
> > facts[0] = txd;
> >
> > return facts;
> > }
> >
> >
> > In my app, I neeed to retrieve this 1st item, I am trying the following
> >
> > object fact = fc.CreateFacts(RSSetInfo);
> >
> > I need something like that
> >
> > TypedXmlDocument test = fact[0];
> > but geting error indicating that "CAN NOT APPLY INDEXING WITH [0] to an
> > expression of type object
> >
> > I tried several casting but it is not working
> >
> > Thanks for your help

>
> Try:
>
> object [] fact = fc.CreateFacts(RSSetInfo);
>
> --
> Mike
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
issue type casting derived object to base object Microsoft C# .NET 2 7th Sep 2007 07:26 AM
casting an object to a specific type =?Utf-8?B?U3RldmUgVGVlcGxlcw==?= Microsoft C# .NET 3 15th Apr 2005 04:21 PM
casting an object to a type =?Utf-8?B?U3RldmUgVGVlcGxlcw==?= Microsoft C# .NET 3 15th Apr 2005 07:52 AM
Type casting object type to user defined class or interface Programmer Microsoft C# .NET 6 17th Jan 2004 08:15 AM
newbie question: casting Type as object to function? daisy Microsoft C# .NET 3 10th Dec 2003 01:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 AM.