The C # Programming Language Notes

zhaozj2021-02-16  66

1. Uncomfortable Abstract Even the Abstract Class is not a member of the implementation of the interface, that is, the following is not allowed: interface in_one {void a ();} Abstract class base_one: in_one {} Or is Java convenient, regardless of the original intention of C #, the OUT parameter and pointer's pointer OUT subclass cannot be converted to an OUT base class, if the conversion is allowed, the type security will not be guaranteed; that is, the OUT parameter corresponds to the pointer of the pointer, The parent class's pointer and subclass of the child is not inherited, so it cannot be transformed 3. Forced interface programming is just a general principle for interface programming, but C # provides a mechanism, forcing customer programmers according to the interface Quote your implementation class: Use the full name when rewriting the interface member, and remove the public modification interface a {void a ();} class a_sub: a {void aa () {}}} static void main (String [] args) { ((A) new a_sub ()). A (); // ok! New a_sub (). A (); // error!} 4, @ 取 转 取 取 取 字 转转 转意 理意, but The words become ordinary identifies, do not seem to have a significant difference 5, Struct's constructor custom CTOR does not hide the default non-refined constructor, slightly unexpected, but also reasonable, default non-construct Functions have a good definition of Strus 6, const, readonly const, equivalent to C Static ConstreadOnly equivalent to C Const, Const equivalent to Static Readonly 7, Natural Boxing, UNBOXING STRING S = "ABC"; Object O = S ; int i = 123; Object O = i; not surprised for String examples, why should I treat Int's example? String is the alias of System.String, just treat Int as the alias of System.Int32, is it not very natural? INT is indeed the alias of System.Int32, INT and STRING still have different, and the value after Boxing will be copied. Allowed, different is that C # will be inserted with the source type and target type before and after calling the custom transition operator, if needed; simply; 9, operator overload C in memory by programmer management , Allows the NEW operator to be overloaded, and C # is forgiven for prohibiting the NEW's heavy-duty C arithmetic operator - * / and so on, its combined form =, - =, * =, / = will not be Automatic overloading, C # In order to ensure the semantic consistency, the short-circuit logic operator is automatically overloaded, and the short-circuit feature is no longer short-circuiting, and C # simply prohibits the overloading of them, only Can be varied in the following form: Class test {public static bool operator false (TEST TEST) {Return False;

转载请注明原文地址:https://www.9cbs.com/read-16934.html

New Post(0)