Click here to Skip to main content
15,896,201 members
Home / Discussions / C#
   

C#

 
GeneralImage rotation ?? Pin
azusakt8-Jul-03 23:22
azusakt8-Jul-03 23:22 
GeneralRe: Image rotation Pin
Valeria Bogdevich9-Jul-03 0:08
Valeria Bogdevich9-Jul-03 0:08 
GeneralRe: Image rotation Pin
azusakt9-Jul-03 15:35
azusakt9-Jul-03 15:35 
GeneralRe: Image rotation Pin
Valeria Bogdevich9-Jul-03 20:03
Valeria Bogdevich9-Jul-03 20:03 
GeneralUser Control Property Pin
Tym!8-Jul-03 11:08
Tym!8-Jul-03 11:08 
Generaltransparent user control issue Pin
SimonS8-Jul-03 10:43
SimonS8-Jul-03 10:43 
GeneralSerialization Question Pin
monrobot138-Jul-03 10:01
monrobot138-Jul-03 10:01 
GeneralRe: Serialization Question Pin
Kastro8-Jul-03 17:37
Kastro8-Jul-03 17:37 
Serialization and deserialization of MyClassCollection (and the instances of MyClass that it holds) will work properly so long as you apply SerializableAttribute to both MyClassCollection and MyClass. If either class is not marked with SerializableAttribute you will receive a SerializationException when you try to call BinaryFormatter.Serialize.

The following demonstrates the serialization of your classes:

using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
 
[Serializable()]
public class MyClass {
 
	public MyClass(string name) {
 		_Name = name;
	}
 
	public string Name {
		get { return _Name; }
	}
 
	private string _Name;
 
}
 
[Serializable()]
class MyClassCollection {
 
	public MyClassCollection() {
		_Items = new MyClass[4];
	}
 
	public MyClass this[int index] {
		get { return _Items[index]; }
		set { _Items[index] = value; }
	}
 
	public override string ToString() {
		string result = "MyClassCollection {";
		for (int i = 0; i < _Items.Length; i++)
			result += (i != 0 ? ", " : "") + (_Items[i] != null ? _Items[i].Name : "[null]");
		result += "}";
		return result;
	}
 
	private MyClass[] _Items;
 
	[STAThread]
	static void Main(string[] args) {
		BinaryFormatter formatter = new BinaryFormatter();
		MemoryStream stream = new MemoryStream();
		// Populate collection
		MyClassCollection col = new MyClassCollection();
		col[0] = new MyClass("Item #1");
		col[2] = new MyClass("Item #2");
		Console.WriteLine(col);
		// Serialize collection and reset stream to beginning
		formatter.Serialize(stream, col);
		col = null;
		stream.Seek(0, SeekOrigin.Begin);
		// Deserialize collection
		col = (MyClassCollection)formatter.Deserialize(stream);
		stream.Close();
		Console.WriteLine(col);
		Console.Read();
	}
 
}

Output:
MyClassCollection {Item #1, [null], Item #2, [null]}
MyClassCollection {Item #1, [null], Item #2, [null]}

Hope this helps.
GeneralRe: Serialization Question Pin
monrobot139-Jul-03 2:44
monrobot139-Jul-03 2:44 
GeneralStackOverflowException Pin
zuhx8-Jul-03 9:55
zuhx8-Jul-03 9:55 
GeneralRe: StackOverflowException Pin
Andy Smith8-Jul-03 10:19
Andy Smith8-Jul-03 10:19 
GeneralRe: StackOverflowException Pin
leppie8-Jul-03 13:38
leppie8-Jul-03 13:38 
GeneralRe: StackOverflowException Pin
Anonymous8-Jul-03 18:35
Anonymous8-Jul-03 18:35 
GeneralRe: StackOverflowException Pin
Andy Smith8-Jul-03 18:58
Andy Smith8-Jul-03 18:58 
GeneralI've looked everywhere Pin
mdolby8-Jul-03 8:54
mdolby8-Jul-03 8:54 
GeneralRe: I've looked everywhere Pin
Nathan Blomquist8-Jul-03 9:19
Nathan Blomquist8-Jul-03 9:19 
GeneralPossible creation of comp.std.cli and comp.std.csharp Pin
Eric Gunnerson (msft)8-Jul-03 8:23
Eric Gunnerson (msft)8-Jul-03 8:23 
GeneralClickety Police Pin
leppie8-Jul-03 9:07
leppie8-Jul-03 9:07 
GeneralMaking one user control aware of another Pin
frogb0x8-Jul-03 7:57
frogb0x8-Jul-03 7:57 
GeneralRe: Making one user control aware of another Pin
leppie8-Jul-03 8:34
leppie8-Jul-03 8:34 
GeneralRe: Making one user control aware of another Pin
Not Active8-Jul-03 9:54
mentorNot Active8-Jul-03 9:54 
GeneralHere's my code so far Pin
frogb0x8-Jul-03 10:32
frogb0x8-Jul-03 10:32 
GeneralRe: Here's my code so far Pin
leppie8-Jul-03 13:34
leppie8-Jul-03 13:34 
GeneralRe: Here's my code so far Pin
frogb0x8-Jul-03 13:35
frogb0x8-Jul-03 13:35 
GeneralRe: Here's my code so far Pin
leppie8-Jul-03 14:05
leppie8-Jul-03 14:05 

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.