新建一个类/组件类然后生成解决方案

解决方案 »

  1.   

    下面是使用 C# 编写的简单字符串组件:列表 1. C# 中的组件 (CompCS.cs)using System;namespace CompCS {
       public class StringComponent {
          private string[] StringsSet;      public StringComponent() {
             StringsSet = new string[] {
                "C# String 0",
                "C# String 1",
                "C# String 2",
                "C# String 3"
             };
          }     public string GetString(int index) {
            if ((index < 0) || (index >= 
               StringsSet.Length)) {
               throw new IndexOutOfRangeException();
             }
             return StringsSet[index];
          }      public int Count {
             get { return StringsSet.Length; }
          }
       }
    }