Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to pass xml string to my other class objects using c#.
and after that i want to concatinate that xml string in my string type variable.
and i need to call it when my other class will get call.
Posted
Comments
Tomasino.7 15-Dec-11 9:41am    
Put them on session
(Session["Text"]=Youttextboxname.Text;)
OriginalGriff 15-Dec-11 9:55am    
That doesn't make a whole lot of sense:
Is this web, or winforms?
Why is passing a string causing your difficulties?
What call will your class get?
Use the "Improve question" widget to edit your question and provide better information.

1 solution

I think one of the neat approaches would be to use class properties which you can set and make readonly if you want once set then no other class modifies the value.

Below is Class1 and Class2:
C#
//Set property MyXml for Class2 like so:
public class Class1
{
    //e.g. I do it in the constructor here:
    public Class1( String myXml )
    {
        Class2 class2 = new Class2();
        class2.MyXml = myXml;
        //we are done here!
    }
}

public class Class2
{
   //class1 properties
   public String MyXml
   {
       get;set;
   }
   
   //access this property with the "this.MyXml" anywhere inside this class (Class2)
}


More on properties? there goes it:
http://msdn.microsoft.com/en-us/library/x9fsa0sw%28v=vs.80%29.aspx[^]

Happy coding,
Morgs
 
Share this answer
 
Comments
prince_rumeel 15-Dec-11 10:19am    
this is a good example.thanks alot.all other also can give me this shor of example.but they just know to hurt others :(

thanks morgs when ever i ask a question you always reply me in good way.thanks alot. :)
Morgs Morgan 15-Dec-11 12:20pm    
U are welcome ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900