C#英语笔记Day 22

1.词汇

  • unknown 未知的
  • reference type 引用类型
  • value type 值类型

2.例句

  • I’m sure it’ll be a familiar problem to you, especially if you’ve done a lot of work with databases.

    我相信对你来说这是一个非常熟悉的问题, 特别是如果你操作过数据库。

  • In some cases, you may not know the price.

    在一些场合,你可能不知道价格。

  • If decimal were a reference type, you could just use null to represent the unknown price, but since it’s a value type.

    如果decimal是一个引用类型,我们就可以使用null去代表未知的价格,但是它是一个值类型,我们不能那样做。

  • There are three common alternatives:

    这里有三种通用替代方案:

  • a.Create a reference type wrapper around decimal.

    a.创建一个引用类型,把值类型decimal包裹起来。

  • b.Maintain a separate Boolean flag indicating whether the price is known.

    b.维护一个单独的标志布尔变量以判断价格是否有值。

  • c.Use a “magic value” (decimal.MinValue, for example) to represent the unknown price.

    c.使用魔术值(比如decimal.MinValue)去代表未知的价格。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。