zoukankan      html  css  js  c++  java
  • 今天抽点时间来说一个C#里的关键字及它们的原型

    关键字是为了方便大家使用,而特意为.net拿出来直接使用的类型,如int,short,long,string,delegate及enum等类型都是关键字,现在说一下它们的原型(F2键,转到定义可以看到)

    int  => public struct Int32
    short => public struct Int16
    long => public struct Int64
    string => public sealed class String
    enum => public abstract class Enum
    delegate =>  public abstract class Delegate 
     
    当我们使用int时,Int32结构体里的常量,属性,方法我们都可以使用,这是为什么呢,这是因为int是int32的一个别名,我们在C#里可以使用using int=Int32来实现,但注意本语句必须放在名称空间里的第一行才可以。
    例如:
    namespace ConsoleApplication1
    {
        using zzl = Zzl;
     
        class Program
        {
            static void Main(string[] args)
            {
                zzl.Hello();
                
            }
        }
     
        class Zzl
        {
            public static void Hello()
            {
                Console.WriteLine("Hello My Item");
            }
     
        }
    }
  • 相关阅读:
    【Codeforces 349B】Color the Fence
    【Codeforces 459D】Pashmak and Parmida's problem
    【Codeforces 467C】George and Job
    【Codeforces 161D】Distance in Tree
    【Codeforces 522A】Reposts
    【Codeforces 225C】Barcode
    【Codeforces 446A】DZY Loves Sequences
    【Codeforces 429B】Working out
    【Codeforces 478C】Table Decorations
    【Codeforces 478C】Table Decorations
  • 原文地址:https://www.cnblogs.com/lori/p/2144628.html
Copyright © 2011-2022 走看看