非静态方法的简单的例子

课本的上的一个例子,我写了下来,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLibrary1
{
    public class Class1
    {
        public string Country()
        {
            string strCountry = "实例方法的示例!";
            return strCountry;
        }
        public string stradd()
        {
            class2 class2 = new class2();
            string strField = class2.Cc() + this.Country();
            return strField;
        }
    }
    class class2
    {
        public string Cc()
        {
            string strCc = "这是一个";
            return strCc;
        }
        static void Main(string[] args)
        {
            Class1 class1 = new Class1();
            Console.WriteLine(class1.stradd());
        }
    }
}

posted on 2008-07-28 18:00  9who  阅读(249)  评论(0编辑  收藏  举报

导航