当前位置: 首页 > wzjs >正文

软件定制开发订单无锡百度关键词优化

软件定制开发订单,无锡百度关键词优化,怎么做百度提交入口网站,wordpress页面判断85. What are anonymous types? 匿名类型是在需要的地方直接定义的类型,甚至都 不给它命名。它非常适合我们这种用例——类型小且临时,而且我们无意在其 他地方使用它 匿名类型是直接从 System.Object 派生的类对象。它们不能转换为任何 其他类型。●…
85. What are anonymous types?

匿名类型是在需要的地方直接定义的类型,甚至都 不给它命名。它非常适合我们这种用例——类型小且临时,而且我们无意在其 他地方使用它

  1. 匿名类型是直接从 System.Object 派生的类对象。它们不能转换为任何 其他类型。
  2. ● 它们重写了 `Equals` 和 `GetHashCode` 方法以支持基于值的相等性。具 有相同值的两个匿名对象将具有相同的哈希码,并且 `Equals` 方法将 返回 `true`。请注意,`==` 运算符未被重载,因此它将返回 `false` (因为它们的引用不同)。
  3. ● 它们支持使用“with”关键字进行非破坏性修改。记住:非破坏性修 改不是改变原始对象,而是创建一个具有修改后值的新对象。

Can we modify the value of an anonymous type property? 否。所有匿名类 型的属性都是只读的

When should we, and should we not use anonymous types? 匿名类型的最佳使用场景是当我们想要使用的类型简单且仅限于某个 特定上下文,并且不会在其他地方使用时。它通常在复杂的 LINQ 查询 中用作临时对象。如果类型复杂或者我们想要重复使用它,就不应该使 用匿名类型。此外,匿名类型只能提供只读属性;它们不能有方法、字段、 事件等,所以如果需要这些功能,匿名类型就不适用了

Are anonymous types value or reference types? 它们是引用类型,因为它们是类,但它们通过 `Equals` 方法支持基于值的 相等性比较。换句话说,即使两个匿名对象的引用不同,只要它们的属性值 相同,`Equals` 方法也会认为它们相等

92. What is the Observer design pattern?
var bitcoinPriceReader = new BitcoinPriceReader();var emailPriceChangeNotifier = new EmailPriceChangeNotifier(25000);
bitcoinPriceReader.AttachObserver(emailPriceChangeNotifier);var pushPriceChangeNotifier = new PushPriceChangeNotifier(40000);
bitcoinPriceReader.AttachObserver(pushPriceChangeNotifier);bitcoinPriceReader.ReadCurrentPrice();
bitcoinPriceReader.ReadCurrentPrice();Console.WriteLine("Push notifications OFF");
bitcoinPriceReader.DetachObserver(pushPriceChangeNotifier);bitcoinPriceReader.ReadCurrentPrice();Console.ReadKey();//首先,让我们定义 IObserver 接口,该接口将由电子邮件价格变化通知器和推送价格变化通知器实现。
public interface IObserver<TData>
{void Update(TData data);
}public interface IObservable<TData>
{void AttachObserver(IObserver<TData> observer);void DetachObserver(IObserver<TData> observer);void NotifyObservers();
}//可观察对象:读取价格
public class BitcoinPriceReader : IObservable<decimal>
{private decimal _currentBitcoinPrice;//。首先,我们需要定义一个观察者集合:private List<IObserver<decimal>> _observers = new List<IObserver<decimal>>();public void AttachObserver(IObserver<decimal> observer){_observers.Add(observer);}public void DetachObserver(IObserver<decimal> observer){_observers.Remove(observer);}//NotifyObservers 方法将简单地遍历观察者列表,并使用 _currentBitcoinPrice对其执行 Update 方法:public void NotifyObservers(){foreach (var observer in _observers){observer.Update(_currentBitcoinPrice);}}public void ReadCurrentPrice(){_currentBitcoinPrice = new Random().Next(0, 50000);NotifyObservers();}
}//观察者:等待接收价格变动通知的类
public class EmailPriceChangeNotifier : IObserver<decimal>
{private readonly decimal _notificationThreshold;public EmailPriceChangeNotifier(decimal notificationThreshold){_notificationThreshold = notificationThreshold;}public void Update(decimal currentBitcoinPrice){if (currentBitcoinPrice > _notificationThreshold){Console.WriteLine($"Sending an email saying that " +$"the Bitcoin price exceeded {_notificationThreshold} " +$"and is now {currentBitcoinPrice}\n");}}
}public class PushPriceChangeNotifier : IObserver<decimal>
{private readonly decimal _notificationThreshold;public PushPriceChangeNotifier(decimal notificationThreshold){_notificationThreshold = notificationThreshold;}public void Update(decimal currentBitcoinPrice){if (currentBitcoinPrice > _notificationThreshold){Console.WriteLine($"Sending a push notification saying that " +$"the Bitcoin price exceeded {_notificationThreshold} " +$"and is now {currentBitcoinPrice}\n");}}
}

In the Observer design pattern, what is the Observable and what is the Observer? 可观察对象是被观察者所观察的对象。可观察对象会将自身状态的变化 通知给观察者

http://www.dtcms.com/wzjs/341129.html

相关文章:

  • 怎么做动态网站php企业查询
  • 网站续费服务内容百度怎么发帖子
  • 医院网站如何建立百度快照是啥
  • 网站开发包括几个部分哪里的网络推广培训好
  • 遵义相亲平台上海城市分站seo
  • 美食网站建设背景北京网站优化哪家好
  • 商城网站模板html链接搜索
  • 不用域名推广网站免费做网站网站
  • 程序员做笔记的网站如何用模板建站
  • 广东世纪达建设集团有限公司官方网站优化软件刷排名seo
  • 提供网站建设公司建站平台哪家好
  • seo推广渠道有哪些外贸网站优化公司
  • 潍坊专业网站建设怎么收费浙江搜索引擎优化
  • 方太网站谁做的自媒体视频发布平台
  • 慕枫网站建设瑞昌网络推广
  • wordpress 菜单栏调用seo免费工具
  • 介绍网站建设爆款引流推广软件
  • 有域名怎么建设网站数字经济发展情况报告
  • 安徽安能建设集团网站站长工具seo综合查询推广
  • 用fullpage做的网站怎么制作属于自己的网址
  • 网站建设运营维护方案安卓手机优化软件哪个好
  • 网站建设+公司搜索引擎优化培训中心
  • 官方网站下载qq音速网络销售靠谱吗
  • 重庆营销网站制作新闻最近新闻10条
  • 小企业网站源码seo如何优化关键词上首页
  • 谁有做爰网站号常州网站建设
  • 全国建设地产网站在线crm系统
  • 微网站 微信网络推广平台有哪些公司
  • 古典网站建设品牌运营公司
  • 建设网站的主要功能有哪些做网络推广需要多少钱