
logo.gif
using System;
using System.Drawing;
using System.Resources;

class resource

...{
static void Main(string []args)

...{
ResourceWriter rw=new ResourceWriter("Demo.resources");
using(Image image=Image.FromFile("logo.gif"))

...{
rw.AddResource("logo",image);
rw.AddResource("Title","C# Program");
rw.AddResource("Author","Hello World!");
rw.Close();
}
}
}
csc string.cs
运行string.exe
生成Demo.resouuces资源文件。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Reflection;
using System.Resources;

static class Program

...{
static void Main()

...{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}

public class Form1 : Form

...{
public Form1()

...{
InitializeComponent();
Assembly assembly=Assembly.GetExecutingAssembly();
rm=new ResourceManager("Demo",assembly);
logo.Image=(Image)rm.GetObject("logo");
}
private void Form1_Load(object sender, EventArgs e)

...{
}

private void InitializeComponent()

...{
this.logo = new System.Windows.Forms.PictureBox();
this.Anthor = new System.Windows.Forms.Label();
this.Cource = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.logo)).BeginInit();
this.SuspendLayout();

this.logo.Location = new System.Drawing.Point(87, 12);
this.logo.Name = "logo";
this.logo.Size = new System.Drawing.Size(200, 180);
this.logo.TabIndex = 0;
this.logo.TabStop = false;

this.Anthor.AutoSize = true;
this.Anthor.Location = new System.Drawing.Point(148, 252);
this.Anthor.Name = "Anthor";
this.Anthor.Size = new System.Drawing.Size(35, 13);
this.Anthor.TabIndex = 1;
this.Anthor.Text = "label1";

this.Cource.AutoSize = true;
this.Cource.Location = new System.Drawing.Point(148, 205);
this.Cource.Name = "Cource";
this.Cource.Size = new System.Drawing.Size(35, 13);
this.Cource.TabIndex = 2;
this.Cource.Text = "label1";

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(393, 380);
this.Controls.Add(this.Cource);
this.Controls.Add(this.Anthor);
this.Controls.Add(this.logo);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.logo)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

}

private System.Resources.ResourceManager rm;
private System.Windows.Forms.PictureBox logo;
private System.Windows.Forms.Label Anthor;
private System.Windows.Forms.Label Cource;
}

csc /resource:demo.resources form.cs
运行form.exe
