继承人很容易... [英] heres a nice easy one...

查看:83
本文介绍了继承人很容易...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#常量的命名约定?


我们对什么是更好的以及更常见的使用
有轻微争议?


(更好=很容易看到常量,很好看的代码和大多数

与其他人正在做的一致)


应该是

private const string InternalCode =" ABC";





private const string _internal_code =" ABC";





private const string INTERNAL_CODE =" ABC";


欢迎所有想法


Sam Martin

naming conventions for C# constants?

we''re having a mild dispute as to what is better and what is more commonly
used?

(better = easy to see as constant, nice to look at in code and most
consistant with what everyone else is doing)

should it be
private const string InternalCode = "ABC";

or

private const string _internal_code = "ABC";

or

private const string INTERNAL_CODE = "ABC";

all ideas welcome

Sam Martin

推荐答案

对于常数也可以从课外到达(公共,内部

和/或受保护)

i更喜欢:

public const string InternalCode =" ABC" ;;


对于我使用的私有常量:

private const string _INTERNAL_CODE =" ABC&quo t ;;


对于我使用的局部常量:

const string INTERNAL_CODE =" ABC";

-

问候,

DennisJDMyrén

Oslo Kodebureau

" Sam Martin" < SA ********* @ yahoo.co.uk>在消息中写道

news:er ************** @ TK2MSFTNGP12.phx.gbl ...
For constants which are also reached from outside the class(public, internal
and/or protected)
i prefer:
public const string InternalCode = "ABC";

For private constants i use:
private const string _INTERNAL_CODE = "ABC";

For local constants i use:
const string INTERNAL_CODE = "ABC";
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
C#常量的命名约定?

我们对什么是更好的以及更常用的是什么有轻微的争议?

(更好=很容易看到不变,很高兴看到代码和大多数
与其他人正在做的事情一致)

应该是
私有const字符串InternalCode =" ABC" ;;
<私有const字符串_internal_code =" ABC" ;;



私有const字符串INTERNAL_CODE =" ABC" ;;

欢迎所有想法

Sam Martin
naming conventions for C# constants?

we''re having a mild dispute as to what is better and what is more commonly
used?

(better = easy to see as constant, nice to look at in code and most
consistant with what everyone else is doing)

should it be
private const string InternalCode = "ABC";

or

private const string _internal_code = "ABC";

or

private const string INTERNAL_CODE = "ABC";

all ideas welcome

Sam Martin



嗨Sam,


Sam Martin < SA ********* @ yahoo.co.uk>在消息中写道

news:er ************** @ TK2MSFTNGP12.phx.gbl ...
Hi Sam,

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
C#常量的命名约定?

我们对什么是更好的以及更常用的是什么有轻微的争议?

(更好=很容易看到不变,很高兴看到代码和大多数
与其他人正在做的事情一致)

应该是
私有const字符串InternalCode =" ABC" ;;
<私有const字符串_internal_code =" ABC" ;;



私有const字符串INTERNAL_CODE =" ABC" ;;

欢迎所有想法

Sam Martin
naming conventions for C# constants?

we''re having a mild dispute as to what is better and what is more commonly
used?

(better = easy to see as constant, nice to look at in code and most
consistant with what everyone else is doing)

should it be
private const string InternalCode = "ABC";

or

private const string _internal_code = "ABC";

or

private const string INTERNAL_CODE = "ABC";

all ideas welcome

Sam Martin




我最喜欢的编码标准是用私有成员变量加前缀

下划线。似乎传统的常量标准是ALL

CAPS,由下划线分隔的术语。将两者结合起来:


private const _INTERNAL_CODE =" ABC" ;;


只是我的



My favored coding standard is to prefix private member variables with an
underscore. It also seems that the traditional standard for constants is ALL
CAPS, terms seperated by underscores. Combining the two you would have:

private const _INTERNAL_CODE = "ABC";

Just my


0.02,当然。


问候,

Daniel
0.02, of course.

Regards,
Daniel


这篇关于继承人很容易...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆