您的位置:首页 > Web前端

C# language features that are rarely used but can be useful

2012-03-27 07:15 267 查看
Various small points that it doesn't matter too much if you don't know or use them

'@' symbol

apart from being used in front of a string to change how compiler interpret the string (verbatim or not), it can be placed also in front of a variable which may otherwise conflict with observed word:

http://stackoverflow.com/questions/429529/what-does-the-symbol-before-a-variable-name-mean-in-c

'??' symbol

null coalesce operator, basically 'A ?? B' is equavalent to expression with tertiary operator 'A != null ? A : B', which when made a sequence may allow you to choose the first non-null:

string answer = answer1 ?? answer2 ?? answer 3 ?? ...

http://stackoverflow.com/questions/446835/what-do-two-question-marks-together-mean-in-c

(To be continued ...)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐