类文件 db.class 代码如下using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
class Child
{
    private int age;
    private string name;    // Default constructor:
    public Child()
    { name = "N/A"; }    // Constructor:
    public Child(string name, int age)
    {
        this.name = name;
        this.age = age;
    }    // Printing method:
    public void PrintChild()
    { Console.WriteLine("{0}, {1} years old.", name, age); }
} public class StringTest
{
     public StringTest()
    {
        // Create objects by using the new operator:
        Child child1 = new Child("Craig", 11);
        Child child2 = new Child("Sally", 10);
                // Create an object using the default constructor:
        Child child3 = new Child();        // Display results:
        Console.Write("Child #1: ");
        child1.PrintChild();
        Console.Write("Child #2: ");
        child2.PrintChild();
        Console.Write("Child #3: ");
        child3.PrintChild();
      
    }
}
/* Output:
    Child #1: Craig, 11 years old.
    Child #2: Sally, 10 years old.
    Child #3: N/A, 0 years old.那么在页面 1.aspx 中如何调用呢?
使显示结果为
/* Output:
    Child #1: Craig, 11 years old.
    Child #2: Sally, 10 years old.
    Child #3: N/A, 0 years old.非常感谢

解决方案 »

  1.   

    能否给一个  1.aspx.cs  调用代码
      

  2.   

    Child child1 = new Child("Craig", 11); //根据需要构造类的实例
    child1.PrintChild();  //调用类里的打印方法
      

  3.   

    //最好声明命名空间吧
    namespace ns1
    {
       class Child
       {
         ......
       }
        public class StringTest
      {
      ......
       }
        
    }//调用
    StringTest st= new StringTest();
    st.StringTest();
      

  4.   

    //调用
    StringTest st= new StringTest();
    st.StringTest();
      中st.StringTest(); 是无效的
      

  5.   

    response.write输出
    TextWriterTraceListener   myWriter   =   new 
      TextWriterTraceListener(System.Console.Out); 
      Debug.Listeners.Add(myWriter); 
    Debug.Write( " ");