C # basic question list-general questions for interviews)

Source: Internet
Author: User
Tags try catch

1. What is the difference between string STR = new string ("A") and string STR = "?

String STR = "A"; this is just a reference. If "A" exists in the memory, STR points to it, if the string "a" is used in the future, use string str1 = "A"; string str2 = ""; string str2 = "A"; all four variables share a string "A" while string STR = new string (""); is to construct a String object again based on the string object "A", and assign the reference of the newly constructed string object to Str

2. Determine whether the string variable STR is null. Which of the three methods has better performance? A, STR = ""; B, STR = string. empty; C, str. length = 0 ;?

The answer is "C". I will leave it alone.

3. Differences between string and string

The string and INT types are defined by C #, while the string and int32 types are. Net types, that is, the CTS type;
String is the alias of system. string in the. NET Framework.
The string is converted to the string class during compilation.

4. What are the differences between virtual and abstract methods?

One: Abstract METHODS only have declarations, without any implementation, such as abstract somemethod (); but virtual methods cannot.
Ii. Subclass inherits the parent class and can rewrite, overwrite, and not process the Virtual Methods in the parent class (see figure 5). abstract methods must be implemented.

5. What are the differences between the override and new methods in the parent class for subclass processing?

There are parent class parentclass and Child class childclass, and virtual method virtualmethod of parent class. There areProgramSection:
Parentclass Pc = new childclass ();
PC. virtualmethod (...);
If the subclass is the virtualmethod of the override parent class, the statement in the second row above will call this method of the subclass.
If the subclass overwrites the virtualmethod of the (new) parent class, the statement in the second row above will call the method of the parent class.

6. Differences between abstract and Interface

Abstract classes can have their own implementations, but interfaces only have declarations. They can have their own static data fields;
Java and C # can implement multiple interfaces, but can inherit only one abstract class (or non-abstract class) (single inheritance, different from C ++'s multi-inheritance );

**************************************** **************************************** ***********************************

If your resume says "familiar ",/UnderstandingC #", Then you should be able to answer the following basic questions. I will give my own brief answers for your reference. Welcome to the discussion.
For "proficient", see: http://www.cnblogs.com/dflying/archive/2006/04/01/364458.html

  1. TheSetWhat is the name of the implicit parameter of the method?
    ValueIt has the same type as the attribute.
  2. HowC #?
    Add a colon after the class name and the name of the base class.
  3. C #Does it support multiple inheritance?
    Not supported. It can be implemented through interfaces.
  4. QuiltProtectedModified attributes/Where can the methods be accessed?
    It can be accessed in the subclass that inherits or indirectly inherits from this class.
  5. Will private members be inherited?
    Yes, but cannot be accessed. So it seems that they cannot be inherited, but they are actually inherited.
  6. Describe the ModifierProtected internal.
    QuiltProtected internalModified attributes/The method can only be (Assembly.
  7. C #Provides a default non-parameter constructor. When I implement another constructor with a parameter, I want to retain this non-parameter constructor. How many constructors should I write?
    Two, once you implement a constructor,C #The default constructor will no longer be provided, so you need to manually implement the non-parameter constructor.
  8. C #What is the common base class of all objects in?
    System. object.
  9. What is the difference between heavy load and overwriting?
    Overload provides the implementation of calling different parameters for a method signature. Overwriting provides the implementation of modifying the behavior of the parent class method in the subclass.
  10. In the method definition,VirtualWhat does it mean?
    QuiltVirtualThe modifier can be overwritten by a quilt.
  11. Can I override non-static methods into static methods?
    No. The signature of the overwriting method must be consistent with that of the overwriting method.VirtualChangeOverride.
  12. Can I override a private virtual method?
    No, or even the sub-classes cannot access the private methods in the parent class.
  13. Can a class be prevented from being inherited by other classes?
    Yes. Use keywords.Sealed.
  14. Can a class be inherited, but cannot a method be overwritten?
    Yes. Mark this classPublicAnd mark this methodSealed.
  15. What is an abstract class (Abstract class)?
    A class that cannot be instantiated. Abstract classes generally contain abstract methods. Of course, they can also be implemented. An inherited class can be instantiated only when abstract methods of all abstract classes are implemented.
  16. When must a class be declared as an abstract class?
    When this class contains abstract methods, or the class does not fully implement the abstract methods of the parent class.
  17. Interface (Interface) What is it?
    Contains only common Abstract METHODS (Public abstract Method. These methods must be implemented in the subclass.
  18. Why cannot I specify a modifier for a method in an interface?
    The methods in the interface are used to define the contract for communication between objects. It is meaningless to specify the methods in the interface as private or protected. They are public methods by default.
  19. Can I inherit multiple interfaces?
    Of course.
  20. What if there are repeated method names in these interfaces?
    In this case, you can decide how to implement it. Of course, you must be very careful. However, there is no problem in the compilation process.
  21. What is the difference between an interface and an abstract class?
    All methods in the interface must be abstract and the access modifier of the method cannot be specified. Abstract classes can be implemented by methods, or you can specify the access modifier of methods.
  22. How do I distinguish between overload methods?
    Different parameter types, different parameter numbers, and different parameter order.
  23. ConstAndReadonlyWhat is the difference?
    ConstKeyword is used to declare the number of compile times,ReadonlyUsed to declare the runtime volume.
  24. System. StringAndSystem. stringbuilderWhat is the difference?
    System. StringIs an unchangeable string.System. stringbuilderStores a variable string and provides some methods to modify the string.

Questions that should be taken into consideration in advance during the interview with senior developers. net

(To clarify, the purpose of my post is not to specifically evaluate the quality of these questions. In fact, my company will examine these questions. What can be answered can be either of them. If you think these questions are very simple, there will be no problems in the. NET interview process. You are also welcome to provide more questions. If you still don't know, you might as well calm down and think about it (or search for it in 15 seconds). There is no need to spend too much time on the rationality of the attack. After all, almost all interviews are like this. If it cannot be changed, let's learn to adapt .)

If your resume says "proficient ",. Net", Then most of the following questions can give a perfect answer. I will give you some ideas later. I also ask you to correct them and participate in the discussion. You are also welcome to give me more questions.
Here are some basic questions: http://www.cnblogs.com/dflying/archive/2006/04/01/364458.html

Note: you must consider "why" and "why not" for every non-problematic judgment ".

  1. ThreadAndProcessWhat is the difference between them?. NetNewApplication domainSo what is the difference between the three of them? IntroducedApplication domainWill there be some potential problems?
  2. Windows ServiceAnd commonEXEWhat are the differences in the execution process?
  3. A process can accessWindowsWhat is the address space? Is it equal to the system's virtual memory size? What impact will these two aspects have on the system design?
  4. EXEAndDLLWhat is the difference between them? How should we choose to use them in system design?
  5. CommonEXEAnd. Net exeIs the execution process different?
  6. What is a weak type and a strong type? In system design, which type should be considered first?
  7. PDBWhat is a file used? What information does it contain?
  8. Cycloramic complexityWhat is it? Why is it important?
  9. CreateCritical SectionWrite a standardLock ()AddDouble check.
  10. Implement standardDisposeMode.
  11. What isFulltrust?Exist inGACInAssemblyYesFulltrust?
  12. What is the following command?Gacutil/L | find/I "system"
  13. What is this command?Sn-t something. dll
  14. Cross-FirewallDCOMWhich port must be opened? Port135What is used?
  15. What can be done with the existingUnmanaged codeIntegration? What should I consider during integration?
  16. Brief explanationOOPAndSOAWhat is it?
  17. XmlserializerHow does it work? Process runningXmlserializerWhat do you need?ACLPermission?
  18. When should I use it during System DesignTry catch? When should I avoid using it?
  19. Debug. Write ()AndTrace. Write ()What is the difference between them? Where should they be used?
  20. Debug buildAndRelease buildWhat is the difference? Is there any obvious difference in execution efficiency?
  21. JITForAssemblyOrMethodWhat happened? Explain why. NetIs the designer?
  22. Brief DescriptionGC.
  23. How should I choose to useAbstract classOrInterface?
  24. How to select a custom typeValue TypeOrReference Type?
  25. ForValue TypeAndReference Type,A. Equals (B)What are the differences between the default implementation methods?
  26. . NetWhy not provide the defaultDeep copy? How to ImplementDeep copy?
  27. Relative. NET 1.1,. Net2.0To avoid excessiveBoxing/unboxingWhat support does the system overhead provide?
  28. StringYesValue TypeOrReference Type? Why?. NetInStringObject is setImmutable?
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.