自定义类中定义两个方法,相互调用

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace Test06
 7 {
 8     //class Class1
 9     //{
10     //    public string Country()
11     //    {
12     //        string strCountry = "方法的示例!";
13     //        return strCountry;
14     //    }
15     //    public string stradd()
16     //    {
17     //        Program myProgram = new Program();
18     //        string strField = myProgram.Cc() + this.Country();
19     //        return strField;
20     //    }
21     //}
22     //class Program
23     //{
24     //    public string Cc()
25     //    {
26     //        string strCc = "这是一个";
27     //        return strCc;
28     //    }
29     //    static void Main(string[] args)
30     //    {
31     //        Class1 class1 = new Class1();
32     //        Console.WriteLine(class1.stradd());
33     //    }
34     //}
35     class Class1   //两个方法
36     {
37         public string exam()
38         {
39             string strexam="方法的示例!";
40             return strexam;
41         }
42         public string add()
43         {
44             Program program = new Program();                       //实例化
45             string stradd = program.xp() + this.exam();
46                 return stradd;
47         }
48     }
49     class Program 
50     {
51         public string xp()
52         {
53             string kt = "这是一个";
54             return kt;
55  
56         }
57   
58         static void Main(string[] args)//(string[] args)顺序别错.Main大写!!!
59         {
60             Class1 class1 = new Class1();                        //实例化
61  Console.WriteLine(class1.add()); 

62 }

63 }

64

65 }
原文地址:https://www.cnblogs.com/liuyaozhi/p/4916094.html