zoukankan      html  css  js  c++  java
  • C# 自定义类中括号取值 测试

        public class ABC : Hashtable{}
        static class Program
        {
            public static ABC  a= new ABC();
            static void Main(string[] args)
            {
                var c = a["0"]; //自定义类中括号取值
            }
        }
            var t = Request.Form["sets"].ToString();
      public abstract class HttpRequest
        {
            public abstract IFormCollection Form { get; set; }
        }
    
        public interface IFormCollection : IEnumerable<KeyValuePair<string, StringValues>>, IEnumerable
        {
      
    
            StringValues this[string key] { get; }
    
            int Count { get; }
         
            ICollection<string> Keys { get; }
    
            IFormFileCollection Files { get; }
    
    
            bool ContainsKey(string key);
    
          
            bool TryGetValue(string key, out StringValues value);
    }
        class Program
        {
            public static ABC a = new ABC();
            static void Main(string[] args)
            {
                var c = a["0"]; //自定义类中括号取值
    
    
            }
        }
        class ABC
        {
    //new 关键字 可以删
    public new string this[string index] { get { return ""; } } }

    //继承  可以使用父类属性

      class Program
        {
            static void Main(string[] args)
            {
                var  test = new test_A();
                var a =  test["0"];
            }
        }
        class test_A:ABC {}
        class ABC
        {
            public  string this[string index] {
                get
                {
                    return "";
                }
            }
        }
  • 相关阅读:
    JavaSE_11_File类、递归
    JavaSE_10_IO流
    leyou_07_对数据的操作
    JavaSE_09_Map
    JavaSE_08_Collections常用功能
    java 22
    java 22
    java 22
    java 22
    java 22
  • 原文地址:https://www.cnblogs.com/enych/p/11458489.html
Copyright © 2011-2022 走看看