Monday, May 31, 2004

Save an image to an XML file

??????----www.fawcette.com/china: "将图片保存到一个XML文件


罗会涛
WinForm的资源文件中,将PictureBox的Image属性等非文字内容都转变成文本保存,这是通过序列化(Serialization)实现的,例子:
//using System.Runtime.Serialization.Formatters.Soap;
Stream stream = new FileStream('E:\\Image.xml',FileMode.Create,FileAccess.Write,FileShare.None);
SoapFormatter f = new SoapFormatter();
Image img = Image.FromFile('E:\\Image.bmp');
f.Serialize(stream,img);
stream.Close();"

Friday, May 28, 2004

C# Tip: Return a Strongly-Typed Array from the ToArray(type) Method

The help of Visual C# doesn't give an example of using the ArrayList's ToArray method. But here's one from MSDN.

Basiclly, if you have a class BinaryString, the following is right

BinaryString[] bs = (BinaryString[])anArrayList.ToArray(typeof(BinaryString));

But the following is wrong:

BinaryString[] bs = (BinaryString[])anArrayList.ToArray();

I think C# 2.0 will make it simple and easy with its feature of generic type.

C#2.0!! C# 2.0!

Sunday, May 23, 2004

IT 新技术, 编程技巧的小博站