骆驼案例方法名称 [英] camel case method names

查看:110
本文介绍了骆驼案例方法名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解使用驼峰式变量名的原因,但我一直想知道为什么要使用驼峰式方法名?为什么是toString()而不是ToString()?它有什么作用?

I understand the reason to camel case variable names, but I've always wondered why you would camel case a method name? why is it toString() and not ToString()? What purpose does it serve?

推荐答案

很多约定说您将类型的首字母大写(类,结构,枚举等),否则使用小写字母(函数,成员等) ).

A lot of conventions say you capitalize the first letter of types (classes, structs, enums, etc.), and use lowercase otherwise (functions, members, etc.).

如果遵循该约定,则只需看一下MyStruct.MyType表示嵌套类型,MyStruct.myData表示某种形式的数据,而MyStruct.myFunc()表示函数调用即可.

If you follow that convention, you can then tell just by looking that MyStruct.MyType refers to a nested type, and MyStruct.myData refers to some form of data, and MyStruct.myFunc() refers to a function call.

这篇关于骆驼案例方法名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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