什么是这个code中的错误?专访 [英] What is the error in this code? Interview

查看:124
本文介绍了什么是这个code中的错误?专访的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在最近的一次采访中我有这个问题。

请告诉我这里的错误?我非常清楚,C#,但我不能看到一个错误。你能吗?

 类X {
     保护字符串T1;
     公众诠释T2;
}
Y类:X {
}
 

解决方案

井方面的错误的,我们可以先而不是。在方面的不好的做法的,实际上它的每一行,在我看来是一个坏主意:

  • 非描述性的类名(X,Y)
  • 在类名不遵循.NET命名约定
  • 非私有字段
  • 非描述性的字段名

基本上,类型字符串 INT 都还可以在这里 - 但其它非空白,非符号令牌需要改变之前,我让这变成codeBase的...

In a recent interview I had this question.

Whats the error here? I know enough c# but I cant see an error. Can you?

Class x {
     protected string t1;
     public int t2;
}
Class y : x {
}

解决方案

Well in terms of errors, we could start with Class instead of class. In terms of bad practice, virtually every line of it is a bad idea in my view:

  • Non-descriptive class names (x, y)
  • Class names which don't follow .NET naming conventions
  • Non-private fields
  • Non-descriptive field names

Basically, the types string and int are okay here - but every other non-whitespace, non-symbolic token would need changing before I let this into a codebase...

这篇关于什么是这个code中的错误?专访的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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