⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 23.5.txt

📁 《Microsoft Visual C# .NET 2003开发技巧大全》源代码
💻 TXT
字号:
Listing 23.5 Programmatically Creating Assemblies
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
namespace _9_DynamicAssembly
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string input;
AnimalBuilder builder = new AnimalBuilder();
Console.WriteLine( “Welcome to the .NET Animal Builder!” );
Console.WriteLine( “This program lets you build an animal and “ +
“ save it as an assembly” );
input = GetInput( “What type of animal do you want?” );
builder.AnimalType = input;
input = GetInput( “What sound does the animal make?” );
builder.AnimalSound = input;
input = GetInput( “How many sounds will it make before it gets” +
“ hoarse (no pun intended)?” );
builder.SoundsBeforeHoarse = Int32.Parse(input);
input = GetInput( “Where would you like to save this animal?” );
builder.BuildAndSaveAnimal( input );
}
static string GetInput( string question )
{
Console.Write( question + “: “ );
return Console.ReadLine();
}
public class AnimalBuilder
{
private string animalType;
private string animalSound;
private int sounds;
public string AnimalType
{
get
{
return animalType;
}
set
{
animalType = value;
}
}
public string AnimalSound
{
get
{
return animalSound;
}
set
{
animalSound = value;
}
}
public int SoundsBeforeHoarse
{
get
{
return sounds;
}
set
{
sounds = value;
}
}
public void BuildAndSaveAnimal( string assemblyPath )
{
}
}
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -