Selection of Unity interview questions (6)

Hongliu Academy will make you a few steps faster.
This article was first published on my official account: Hongliu School

I have sorted out some Unity interview questions, hoping to help you.

Interviewer: What is the meaning of the keywords using and new in C#?

answer:

The using keyword has two main purposes:

  • As a directive to create an alias for a namespace or to import types defined in other namespaces.
  • As a statement, used to define a range at the end of which objects are to be deallocated.

new keyword: create a new instance or hide the parent class method.

Interviewer: What is the difference between System.String and System.StringBuilder?

answer:

  • System.String is an immutable string.
  • System.StringBuilder stores a variable string and provides some methods to modify this string.
  • In the String class, using "+" in the operation of performing string splicing will generate a new object and occupy memory.
  • The StringBuilder class only modifies the content of the string, and does not create new objects.

Interviewer: What is the difference between const and readonly?

answer:

  • A const field can only be initialized within the field's declaration.
  • The static modifier is not allowed on constant declarations.
  • readonly fields can be initialized in declaration or constructor.

Interviewer: What is a delegate in C#? Is an event a kind of delegation?

answer:

A delegate can pass a method as a parameter into another method. A delegate can be understood as a reference to a function.

Events are a special kind of delegate.

Interviewer: Please briefly describe the main difference between ArrayList and List<>.

answer:

ArrayList is a non-generic list. When storing data, all the data is regarded as object type data. There is a boxing problem. When it is taken out and used, there is an unboxing problem. Boxing and unboxing will make performance worse, and there are data security issues. But the advantage is that value types and reference types can be converted to each other.

List is a generic list, and the data type is only defined when it is used. Generics avoid the problem of unboxing. It is faster to store, read and read, and the type is safer.

further reading

Pay attention to the service account of Hongliu Academy and get all the content of this series for free


I'm Dazhi (vx: zhz11235), your technology pathfinder, see you next time!

don't go! Like it , collect it!

OK, you can go.

Guess you like

Origin blog.csdn.net/zhenghongzhi6/article/details/112535041