C # basic Concept 25 Q

Source: Internet
Author: User
Tags abstract modifier

1. What is the difference between a static member and a Non-static member?

2.const and static readonly difference?

What do you mean, 3.extern?

What do you mean, 4.abstract?

What does the 5.internal modifier do?

What does the 6.sealed modifier do?

What is the difference between 7.override and overload?

8. What is an index indicator?

What does a 9.new modifier do?

What does the 10.this keyword mean?

11. Can I use abstract functions to override virtual functions in a base class?

12. Can the sealed class have virtual functions?

13. What is a property accessor?

Can 14.abstract be used with virtual? Can I use it with override?

15. What members can the interface contain?

16. What is the difference between class and structure?

17. What are the problems associated with multiple inheritance of interfaces?

18. What is the difference between an abstract class and an interface?

19. What is the alias indicator?

20. How to manually release resources?

What is 21.p/invoke?

What is the difference between 22.StringBuilder and String?

What is the meaning of 23.explicit and implicit?

What's the use of 24.params?

25. What is reflection?

Here is a reference to my answer (C # language category), if there are inaccurate, not comprehensive, welcome friends to correct me!

1. What is the difference between a static member and a Non-static member?

For:

Static variables are declared with the static modifier, created when the class is instantiated, and accessed through the class

Variables not declared with the static modifier are called non-static variables, created when an object is instantiated, accessed through an object

The same static variable for all instances of a class is the same value, and the same non-static variable of different instances of the same class can be a different value

Non-static members cannot be used in the implementation of static functions, such as non-static variables, non-static functions, etc.

Example:

using System;
using System.Collections.Generic;
using System.Text;
namespace Example01
{
  class Program
  {
    class Class1
    {
      public static String staticStr = "Class";
      public String notstaticStr = "Obj";
    }
    static void Main(string[] args)
    {
      //静态变量通过类进行访问,该类所有实例的同一静态变量都是同一个值
      Console.WriteLine("Class1's staticStr: {0}", Class1.staticStr);
      Class1 tmpObj1 = new Class1();
      tmpObj1.notstaticStr = "tmpObj1";
      Class1 tmpObj2 = new Class1();
      tmpObj2.notstaticStr = "tmpObj2";
      //非静态变量通过对象进行访问,不同对象的同一非静态变量可以有不同的值
      Console.WriteLine("tmpObj1's notstaticStr: {0}", tmpObj1.notstaticStr);
      Console.WriteLine("tmpObj2's notstaticStr: {0}", tmpObj2.notstaticStr);
      Console.ReadLine();
    }
  }
}

Results:

Class1 ' s Staticstr:class

TmpObj1 ' s notstaticstr:tmpobj1

TmpObj2 ' s NOTSTATICSTR:TMPOBJ2

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.