惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
爱范儿
爱范儿
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
Jina AI
Jina AI
Project Zero
Project Zero
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tenable Blog
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
月光博客
月光博客
雷峰网
雷峰网
G
Google Developers Blog
V
V2EX
T
Tor Project blog
罗磊的独立博客
Schneier on Security
Schneier on Security
Know Your Adversary
Know Your Adversary
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy International News Feed
S
Securelist
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
小众软件
小众软件
Scott Helme
Scott Helme
I
Intezer
T
Threat Research - Cisco Blogs
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
C
CERT Recently Published Vulnerability Notes
Security Archives - TechRepublic
Security Archives - TechRepublic
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
L
Lohrmann on Cybersecurity
T
Troy Hunt's Blog
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Latest news
Latest news
AWS News Blog
AWS News Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - KiddLee

数据库存储图像及使用Image控件显示 三层体系结构总结(六) Spring.Core IoC(一) Spring.Net 模块组成 Generating user instances in Sql Server is disabled. Use sp_configure 'user instances enabled' to generate user instances 面向对象分析设计学习与探索(六):好的设计=软件的灵活程度(good design=flexible software)继续 面向对象分析设计学习与探索(六):面向对象的灾难(OO Catastrophe) 面向对象分析设计学习与探索(六):好的设计=软件的灵活程度(good design=flexible software) 面向对象分析设计学习与探索(五):分析(Analysis) 面向对象分析设计学习与探索(四):需求变化(Requirements Change) 面向对象分析设计学习与探索(三):收集需求(Gathering Requirement) 面向对象分析设计学习与探索(二):好的应用程序设计(Well-designed apps rock) 面向对象分析设计学习与探索(一):开篇 类型构造器 装箱拆箱续 Session Cookie and Persistent Cookie 第一次执行方法 我犯错了 装箱拆箱
接口函数还可以声明为private
KiddLee · 2007-03-01 · via 博客园 - KiddLee

                以私有化方式实现接口中的函数,我是第一次听说,下面就来看看:

                首先声明一个接口:

        public interface ITest

    {

        void Test1();

        void Test2();

}

   接下来,我们再来实现接口

    public class Test : ITest

    {

        public void Test1()

        {

            Console.WriteLine("Test1");

        }

        void ITest.Test2()

        {

            Console.WriteLine("Test2");

        }

}

   注意:对于Test2方法是以这种方式来满足接口要求的

   我们再用客户端验证一下:

    class Program

    {

        static void Main(string[] args)

        {

            Test tt = new Test();

            tt.Test1();

            Console.Read();

        }

}

   但是如果我要调用ttTest2方法会发现:



       
实例化的对象已经看不见Test2方法了,那如果我们想调用Test2方法有如何解决呢?我们可以这样做:

        static void Main(string[] args)

        {

            ITest itt = new Test();

            itt.Test1();

            itt.Test2();

            Console.Read();

    }

   以接口对象的方式声明,产生实际对象,这样就可以看见Test2方法了,运行结果是:

Test1

Test2