已有141人关注
求解释下这段代码的流程
发表在C#答疑区 2017-07-05
是否精华
版块置顶:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;


namespace Test06

{

    class Class1

    {

        public string Country()

        {

            string strCountry = "这是一个";

            return strCountry;

        }

        public string stradd()

        {

            Program myProgram = new Program();

            string strField = this.Country() + myProgram.Cc();

            return strField;

        }

    }

    class Program

    {

        public string Cc()

        {

            string strCc = "方法的示例!";

            return strCc;

        }

        static void Main(string[] args)

        {

            Class1 class1 = new Class1();

            Console.WriteLine(class1.stradd());

        }

    }

}


分享到:
精彩评论 1
小禾斗
学分:7308 LV13
TA的每日心情
奋斗
2017-04-21 14:00:25
2017-07-05
沙发

读者朋友:

  您好,在第一个类中先定义了一个Country方法,用来返回一个字符串;然后定义了一个stradd方法,这个方法里面用到了第儿个类的Cc方法,用来返回  Country方法返回的字符串连接上Cc方法返回的字符串。最后在主方法中通过第一个类的对象调用stradd方法进行输出。

首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照