Click here to Skip to main content
15,890,385 members
Home / Discussions / C#
   

C#

 
GeneralRe: Get the process-name that locked the file Pin
Dave Kreskowiak5-Mar-10 7:49
mveDave Kreskowiak5-Mar-10 7:49 
GeneralDon't you just hate it Pin
Ennis Ray Lynch, Jr.5-Mar-10 5:34
Ennis Ray Lynch, Jr.5-Mar-10 5:34 
GeneralRe: Don't you just hate it Pin
J4amieC5-Mar-10 6:03
J4amieC5-Mar-10 6:03 
GeneralThe difference Pin
Ennis Ray Lynch, Jr.5-Mar-10 6:17
Ennis Ray Lynch, Jr.5-Mar-10 6:17 
GeneralRe: The difference Pin
Björn T.J.M. Spruit5-Mar-10 10:35
Björn T.J.M. Spruit5-Mar-10 10:35 
QuestionRequest.BeginGetResponse probem in Windows 7 and unexpected Blocking behaviour Pin
vivasaayi4-Mar-10 23:45
vivasaayi4-Mar-10 23:45 
AnswerRe: Request.BeginGetResponse probem in Windows 7 and unexpected Blocking behaviour (Fixed) Pin
vivasaayi5-Mar-10 0:28
vivasaayi5-Mar-10 0:28 
QuestionProblem while converting class object to string using XmlSerializer Pin
nagendrathecoder4-Mar-10 23:30
nagendrathecoder4-Mar-10 23:30 
Hi All,

I am trying to convert a class object into a string of xml format using XmlSerializer.
My class structure is like this:
namespace test
{
	public class Class1
	{
		public Class1(){}

		private string strStatus = "Active";		
		public string Status
		{
			get { return strStatus; }
			set { strStatus = value;}
		}
		public Class2 Class2 { get; set; }		
	}

	public class Class2
	{
		public Class2(){}

		private string strName = "ABC";
		public string Name
		{
			get { return strName; }
			set { strName = value; }
		}
		public Class3 Class3 { get; set; }
	}

	public class Class3()
	{
		ArrayList Element;
		private int intCount = 0;

		public Class3()
		{
			Element = new ArrayList();
		}
		public int Count
		{
			get { return intCount;}			
		}
		public void Add(Class4 Entry)
		{
			Element.Add(Entry);
			intCount++;
		}
		
		public Class4 this[int index]
		{
			get
			{
				return (Class4)Element[index];
			}
		}
	}

	public class Class4
	{
		public Class4(){}

		private int intSub1;
		private int intSub2;

		public int Sub1
		{
			get {return intSub1;}
			set {intSub1 = value;}
		}
		public int Sub2
		{
			get {return intSub2;}
			set {intSub2 = value;}
		}
	}
}


Now, i am using this code for converting object of Class1 to a string of xml format:
Class1 objClass1 = new Class1();
Class4 objClass4 = new Class4();
objClass4.Sub1 = 68;
objClass4.Sub2 = 73;
objClass1.Class2.Class3.Add(objClass4);

Class4 objClass4Dup = new Class4();
objClass4Dup.Sub1 = 76;
objClass4Dup.Sub2 = 65;
objClass1.Class2.Class3.Add(objClass4Dup);

System.Xml.Serialization.XmlSerializer x = new XmlSerializer(objClass1 .GetType());
StringWriter sw = new StringWriter();
x.Serialize(sw, objClass1);
string strxml = sw.ToString();
MessageBox.Show(strxml);


In the messagebox, i can see values till Class2 properly in xml format.
Then i can see the "Count" of Class3 and its value, but the values of Class4 are not coming into string.

Can anybody tell what i am missing or what i need to do to display values of Class4 into string?

Thanks,
Nagendra.
AnswerMessage Closed Pin
5-Mar-10 1:33
stancrm5-Mar-10 1:33 
GeneralRe: Problem while converting class object to string using XmlSerializer Pin
nagendrathecoder5-Mar-10 1:41
nagendrathecoder5-Mar-10 1:41 
GeneralMessage Closed Pin
5-Mar-10 3:48
stancrm5-Mar-10 3:48 
GeneralRe: Problem while converting class object to string using XmlSerializer Pin
nagendrathecoder5-Mar-10 18:50
nagendrathecoder5-Mar-10 18:50 
GeneralRe: Problem while converting class object to string using XmlSerializer Pin
nagendrathecoder5-Mar-10 2:05
nagendrathecoder5-Mar-10 2:05 
QuestionGet correct case of Filename Pin
DanielWehrle4-Mar-10 20:33
DanielWehrle4-Mar-10 20:33 
AnswerMessage Closed Pin
4-Mar-10 20:38
stancrm4-Mar-10 20:38 
GeneralRe: Get correct case of Filename Pin
DanielWehrle5-Mar-10 4:05
DanielWehrle5-Mar-10 4:05 
AnswerRe: Get correct case of Filename Pin
Calla4-Mar-10 21:29
Calla4-Mar-10 21:29 
GeneralRe: Get correct case of Filename Pin
David Skelly5-Mar-10 1:41
David Skelly5-Mar-10 1:41 
GeneralRe: Get correct case of Filename Pin
AspDotNetDev5-Mar-10 2:08
protectorAspDotNetDev5-Mar-10 2:08 
GeneralRe: Get correct case of Filename Pin
David Skelly5-Mar-10 5:51
David Skelly5-Mar-10 5:51 
GeneralRe: Get correct case of Filename Pin
Dave Kreskowiak5-Mar-10 7:53
mveDave Kreskowiak5-Mar-10 7:53 
GeneralRe: Get correct case of Filename Pin
Luc Pattyn5-Mar-10 1:42
sitebuilderLuc Pattyn5-Mar-10 1:42 
GeneralRe: Get correct case of Filename Pin
AspDotNetDev5-Mar-10 2:12
protectorAspDotNetDev5-Mar-10 2:12 
GeneralRe: Get correct case of Filename Pin
Luc Pattyn5-Mar-10 2:19
sitebuilderLuc Pattyn5-Mar-10 2:19 
GeneralRe: Get correct case of Filename Pin
David Skelly5-Mar-10 6:01
David Skelly5-Mar-10 6:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.