Object Creation in Linked List C#

  • Thread starter sk.rasheedfarhan
  • Start date
S

sk.rasheedfarhan

Hi
I am using C# and my class declaration is like this
namespace UnitTestCaseTool
{
/// <summary>
/// Summary description for RuleParser.
/// </summary>
public class RuleParser
{
public RuleParser()
{
private Object NextItem;
RuleParser RulesProperties;
}

private RuleXMLParser CreateNextNode(RuleXMLParser RulesProperties)
{

step-1: RulesProperties.NextItem = new RuleXMLParser();
step-2: RulesProperties =(RuleXMLParser) RulesProperties.NextItem;
}
}
}

Here my concern is In my first step-1: when I am calling
CreateNextNode function, it is creating new Ruleparser class Object is
it ?
If yes then what I am doing in the Second Step.
i doubt, am i implementing Linked List with Self referential Class ?

Can any body help me.
 
W

wfairl

Hi
I am using C# and my class declaration is like this
namespace UnitTestCaseTool
{
/// <summary>
/// Summary description for RuleParser.
/// </summary>
public class RuleParser
{
public RuleParser()
{
private Object NextItem;
RuleParser RulesProperties;
}

private RuleXMLParser CreateNextNode(RuleXMLParser RulesProperties)
{

step-1: RulesProperties.NextItem = new RuleXMLParser();
step-2: RulesProperties =(RuleXMLParser) RulesProperties.NextItem;

}
}
}

Here my concern is In my first step-1: when I am calling
CreateNextNode function, it is creating new Ruleparser class Object is
it ?
If yes then what I am doing in the Second Step.
i doubt, am i implementing Linked List with Self referential Class ?

Can any body help me.

Step 2 isn't actually doing anything because you're not passing a
reference to the variable (reference to the reference of the object)
so any reference changes will not have any effect outside the
function.

You'd have to add the ref keyword like this:

private RuleXMLParser CreateNextNode(ref RuleXMLParser
RulesProperties)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top