Question serialize & Deserialize entities without using Generics & Reflection?

post98

New member
Joined
Dec 25, 2013
Messages
1
Programming Experience
1-3
I have 2 entities (student, course) that I want to serialize & deserialize without using Generic & Reflection.

This would be in a project three layers and using .NET 1.0.

Any ideas?

I do Serialization/Deserialization methods in both class but there is a error in deserialize error:cannot convert expression type int to return type MyApp_Common.Student

no its not school homework

I do with .netframework4 and reflection but I want do that with .netframework1 and with out use reflection and Generic

C#:
[/FONT][/COLOR][/B][COLOR=blue][FONT=Consolas]private[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] [/FONT][/COLOR][COLOR=blue][FONT=Consolas]string[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] SerializeStudent(Student student)[/FONT][/COLOR]
    {
        [COLOR=blue]return[/COLOR] student.Id.ToString() + [COLOR=purple]'[/COLOR][COLOR=purple],'[/COLOR] + student.FirstName + [COLOR=purple]'[/COLOR][COLOR=purple],'[/COLOR] + student.LastName;
    }
 
    [COLOR=blue]private[/COLOR] Student DeserializeStudent([COLOR=blue]string[/COLOR][] str)
    {
        Student student = [COLOR=blue]new[/COLOR] Student();
 
        [COLOR=blue]return[/COLOR] student.Id = [COLOR=navy]5[/COLOR];
  [COLOR=#000000][FONT=Consolas]    }[/FONT][/COLOR][B][COLOR=#556655][FONT=Segoe UI]

Thanks
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,272
Location
Sydney, Australia
Programming Experience
10+
You are returning the result of this expression:
student.Id = 5
That expression is an assignment so it evaluates to the value that you're assigning, which is 5. If you want to return a Student object then you need to return a Student object. Your 'student' variable is type Student so maybe you should return that.
 
Top Bottom