简体   繁体   中英

How to access variable in a global class not in app_code in asp.net

I have a global class which is not in app_code folder. I have declared a static variable in that class. However since it is not in app_code folder I am not able to access it from another web page. Can anyone help me to access it's contents?

You can access using System.Reflection.MemberInfo info = typeof(YourClass);

   using System;

    [AttributeUsage(AttributeTargets.All)]
      public class Global : System.Attribute
       {
        public string Url;

        public Global(string url)   // url is a positional parameter
        {
        this.Url = url;
        }

      }
       [HelpAttribute("Information on the class MyClass")]
        class YourClass
       {
       }


   namespace AttributeAppl
  {
   class Program
   {
    static void Main(string[] args)
    {
     System.Reflection.MemberInfo info = typeof(MyClass);
     object[] attributes = info.GetCustomAttributes(true);

      Global dbi = (Global )Url;
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM