Click here to Skip to main content
15,900,378 members
Home / Discussions / C#
   

C#

 
GeneralCatching PowerPoint when she falls Pin
Esmo200027-Jan-05 3:55
Esmo200027-Jan-05 3:55 
GeneralRe: Catching PowerPoint when she falls Pin
Heath Stewart27-Jan-05 9:51
protectorHeath Stewart27-Jan-05 9:51 
GeneralRe: Catching PowerPoint when she falls Pin
Esmo200027-Jan-05 10:40
Esmo200027-Jan-05 10:40 
GeneralRe: Catching PowerPoint when she falls Pin
Heath Stewart27-Jan-05 12:04
protectorHeath Stewart27-Jan-05 12:04 
GeneralRe: Catching PowerPoint when she falls Pin
Esmo200031-Jan-05 8:20
Esmo200031-Jan-05 8:20 
GeneralRe: Catching PowerPoint when she falls Pin
Heath Stewart31-Jan-05 9:33
protectorHeath Stewart31-Jan-05 9:33 
QuestionSerialize an Array with ISerializable? Pin
huckfinn27-Jan-05 3:18
huckfinn27-Jan-05 3:18 
AnswerRe: Serialize an Array with ISerializable? Pin
Heath Stewart27-Jan-05 9:59
protectorHeath Stewart27-Jan-05 9:59 
First of all, your comments - and perhaps your thinking - are wrong in the sense that the serialization constructor is to deserialize data, while ISerializable.GetObjectData is to serialize data. You should read Serializing Objects[^] in the .NET Framework SDK for an overview and examples of serialization.

The easiest way to achieve what you want: don't implement ISerializable. Just attribute your class with the SerializableAttribute as you're currently doing. By default, any private or public members of a class are serialized for types that are serializable. If you implement ISerializable just pass the array to the SerializationInfo.AddValue method:
[Serializable]
public class MyClass : ISerializable
{
  MyStruct[] structs;
  protected MyClass(SerializationInfo info, StreamingContext context)
  {
    structs = (MyStruct[])info.GetValue("structs", typeof(MyStruct[]));
  }
  void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
  {
    info.AddValue("structs", structs, typeof(MyStruct[]));
  }
}
 
[Serializable]
public struct MyStruct
{
  public string Field1;
  public int Field2;
  [NonSerialized] public string Field3
  {
    get { return Field1 + Field2.ToString(); }
  }
}


This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
Generaltrouble deleting records from my sql server Pin
tadhg8827-Jan-05 3:17
tadhg8827-Jan-05 3:17 
GeneralRe: trouble deleting records from my sql server Pin
Mazdak28-Jan-05 0:53
Mazdak28-Jan-05 0:53 
GeneralRe: Time Validation in C# Pin
Mazdak27-Jan-05 2:01
Mazdak27-Jan-05 2:01 
GeneralRe: Time Validation in C# Pin
itssuk27-Jan-05 3:01
itssuk27-Jan-05 3:01 
GeneralTime Validation in C# Pin
itssuk27-Jan-05 1:17
itssuk27-Jan-05 1:17 
GeneralNeed help with C# to C++ DLL interaction Pin
lms00727-Jan-05 0:55
lms00727-Jan-05 0:55 
GeneralRe: Need help with C# to C++ DLL interaction Pin
lms00727-Jan-05 1:53
lms00727-Jan-05 1:53 
GeneralRe: Need help with C# to C++ DLL interaction Pin
lms00727-Jan-05 2:17
lms00727-Jan-05 2:17 
GeneralNo overload for method Pin
nikneem200526-Jan-05 23:15
nikneem200526-Jan-05 23:15 
GeneralRe: No overload for method Pin
Stefan Troschuetz26-Jan-05 23:39
Stefan Troschuetz26-Jan-05 23:39 
GeneralRe: No overload for method Pin
J4amieC27-Jan-05 0:08
J4amieC27-Jan-05 0:08 
GeneralRe: No overload for method Pin
nikneem200527-Jan-05 0:19
nikneem200527-Jan-05 0:19 
GeneralRe: No overload for method Pin
J4amieC27-Jan-05 0:03
J4amieC27-Jan-05 0:03 
GeneralSecurity error - windows custom control Pin
26-Jan-05 23:00
suss26-Jan-05 23:00 
GeneralConnection pooling in windows.net Pin
sapnabn26-Jan-05 22:59
sapnabn26-Jan-05 22:59 
GeneralRe: Connection pooling in windows.net Pin
Member 37818926-Jan-05 23:07
Member 37818926-Jan-05 23:07 
GeneralCapturing Video Pin
Deobrat Singh26-Jan-05 22:43
Deobrat Singh26-Jan-05 22:43 

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.