http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 2438|回复: 0

[总群] [2013-01-29]澄泓]IEnumerable<T>中in和Out的作用和用法

[复制链接]
发表于 2013-1-29 10:16:33 | 显示全部楼层 |阅读模式
[深圳]澄泓9:49:00
  1. out关键字的意思是说IEnumerable< T>中T只会被用在输出中,值不会被改变。这样将IEnumerable< string>转为IEnumerable< object>类型就是安全的。

  2.     in的意思正好相反,是说IComparer< T>中的T只会被用在输入中,这样就可以将IComparer< object>安全的转为IComparer< string>类型。
复制代码
深圳-柠檬9:49:16

michael9:49:19
in 代表是参数,out就代码返回值
[深圳]澄泓9:49:33
还没有这样用过
[重庆]版主-Eagle9:49:36
out put
龙冀平9:49:58
呵呵,现在主群比较强大啊
人多才好交流
[重庆]版主-Eagle9:50:45
in 还真没这样用过!

一般都是设定类型
michael9:51:15
这个是4里的特性吧..
&叮咚9:51:26
  1. public interface IComparable < in T>
  2. {
  3.      int CompareTo(T other);
  4. }

  5. public interface IComparable <  T>
  6. {
  7.      int CompareTo(T other);
  8. }
复制代码
[深圳]澄泓9:51:29

michael9:51:34
用于泛型的..
&叮咚9:51:52
  1. public interface IComparable < in T>
  2. {
  3.      int CompareTo(T other);
  4. }

  5. public interface IComparable <  T>
  6. {
  7.      int CompareTo(T other);
  8. }
复制代码
有区别么
michael9:52:00
没有..
&叮咚9:52:13
哦  
michael9:52:14
in是相对于out来说的..
michael9:52:21
有out才会有in
&叮咚9:52:22
感觉有点迷糊
[深圳]澄泓9:53:37
谁搞一篇弄到论坛
michael:54:28
这个有什么迷糊的啊..
[深圳]澄泓9:54:50
没用过
michael9:55:01
如果迷糊,那你的基础还是差了点..
[石家庄]123456 9:55:10
怎么回事
michael9:55:10
这个问题先放放吧..
&叮咚9:55:18
你真牛
[深圳]澄泓9:55:40
[code=csharp]System.Func< in T, …, out R>  System.Action< in T, …>  System.Predicate< in T>  System.Comparison< in T>  System.EventHandler< in T> [/code]
[深圳]澄泓 9:55:53
这玩意都没有用过
[石家庄]123456 9:56:12
牛人呀
[厦门]龙冀平9:56:27
膜拜


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-4-30 04:01

© 2014-2021

快速回复 返回顶部 返回列表