Click here to Skip to main content
15,921,660 members
Home / Discussions / C#
   

C#

 
Questiongroupbox behavior Pin
electriac30-Nov-08 6:36
electriac30-Nov-08 6:36 
AnswerRe: groupbox behavior Pin
Wendelius30-Nov-08 11:33
mentorWendelius30-Nov-08 11:33 
GeneralRe: groupbox behavior Pin
Luc Pattyn30-Nov-08 11:48
sitebuilderLuc Pattyn30-Nov-08 11:48 
GeneralRe: groupbox behavior Pin
electriac30-Nov-08 12:09
electriac30-Nov-08 12:09 
GeneralRe: groupbox behavior Pin
Luc Pattyn30-Nov-08 12:27
sitebuilderLuc Pattyn30-Nov-08 12:27 
GeneralRe: groupbox behavior Pin
electriac30-Nov-08 15:16
electriac30-Nov-08 15:16 
GeneralRe: groupbox behavior Pin
Luc Pattyn30-Nov-08 15:43
sitebuilderLuc Pattyn30-Nov-08 15:43 
Questiondeserialize issue Pin
George_George30-Nov-08 3:45
George_George30-Nov-08 3:45 
Hello everyone,

I am using the following code to serialize a Type1 object instance and deserialize the object instance into a Type2 object instance.

There is exception when I deserialize, which says can not convert from Type1 to Type2. My question is, even if the content of two types are compatible (both Type1 and Type2 contain a single int field), we can not deserialize into different types?

[Serializable]
public class Type1
{
    public int abc;
}

[Serializable]
public class Type2
{
    public int cba;
}

public class Program
{
    static void Main(string[] args)
    {
        Type1 input = new Type1();
        input.abc = 12345;
        Type2 output = new Type2();

        IFormatter formatter = new BinaryFormatter();
        Stream stream = new FileStream("output.bin", FileMode.Create, FileAccess.Write, FileShare.None);
        formatter.Serialize(stream, input);
        stream.Close();

        stream = new FileStream("output.bin", FileMode.Open, FileAccess.Read, FileShare.None);
        output = (Type2)formatter.Deserialize(stream);

        return;
    }
}



thanks in advance,
George
AnswerRe: deserialize issue [modified] Pin
User 665830-Nov-08 3:58
User 665830-Nov-08 3:58 
AnswerRe: deserialize issue Pin
Giorgi Dalakishvili30-Nov-08 4:20
mentorGiorgi Dalakishvili30-Nov-08 4:20 
QuestionImplementing Audit Trail for Objects in C#? Pin
abmv30-Nov-08 3:25
professionalabmv30-Nov-08 3:25 
AnswerRe: Implementing Audit Trail for Objects in C#? Pin
User 665830-Nov-08 4:03
User 665830-Nov-08 4:03 
GeneralRe: Implementing Audit Trail for Objects in C#? Pin
abmv30-Nov-08 6:35
professionalabmv30-Nov-08 6:35 
AnswerRe: Implementing Audit Trail for Objects in C#? Pin
Pete O'Hanlon30-Nov-08 9:40
mvePete O'Hanlon30-Nov-08 9:40 
QuestionCreating an Alias to SQL Server and configure remote access control via code ? Pin
calanit30-Nov-08 1:13
calanit30-Nov-08 1:13 
AnswerRe: Creating an Alias to SQL Server and configure remote access control via code ? Pin
Wendelius30-Nov-08 4:03
mentorWendelius30-Nov-08 4:03 
GeneralRe: Creating an Alias to SQL Server and configure remote access control via code ? Pin
calanit30-Nov-08 5:44
calanit30-Nov-08 5:44 
GeneralRe: Creating an Alias to SQL Server and configure remote access control via code ? Pin
Wendelius30-Nov-08 6:21
mentorWendelius30-Nov-08 6:21 
GeneralRe: Creating an Alias to SQL Server and configure remote access control via code ? Pin
calanit30-Nov-08 22:44
calanit30-Nov-08 22:44 
GeneralRe: Creating an Alias to SQL Server and configure remote access control via code ? Pin
Wendelius1-Dec-08 4:39
mentorWendelius1-Dec-08 4:39 
QuestionC# Windows form Applications Pin
Karmendra Suthar29-Nov-08 21:05
Karmendra Suthar29-Nov-08 21:05 
AnswerRe: C# Windows form Applications Pin
Nishant Singh29-Nov-08 21:12
Nishant Singh29-Nov-08 21:12 
AnswerRe: C# Windows form Applications Pin
nelsonpaixao30-Nov-08 4:10
nelsonpaixao30-Nov-08 4:10 
QuestionRequest.QueryString Question. Pin
Jacob D Dixon29-Nov-08 19:13
Jacob D Dixon29-Nov-08 19:13 
AnswerRe: Request.QueryString Question. Pin
Guffa29-Nov-08 21:14
Guffa29-Nov-08 21:14 

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.