Cerebrus

Static (Global) Class

Mar 29th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. //Related to Question at:
  2. //http://groups.google.com/group/dotnetdevelopment/browse_thread/thread/a5c0e565de89bff0/
  3. //Original Date of pasting: Jul 14th, 2010
  4. //Original URL: http://pastebin.com/KF61pNCe
  5.  
  6. //Person.cs
  7. //*****************
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12.  
  13. namespace testglobalclass2
  14. {
  15.     public class Person
  16.     {
  17.      string PersonName;
  18.  
  19.         public Person(string PersonName)
  20.         {
  21.          this.PersonName = PersonName;
  22.         }
  23.  
  24.         public string Personname
  25.         {
  26.          get { return Personname; }
  27.  
  28.         }
  29.  
  30.     }
  31. }
  32.  
  33.  
  34. //Group.cs
  35. //*****************
  36. using System;
  37. using System.Collections.Generic;
  38. using System.Linq;
  39. using System.Text;
  40.  
  41. namespace testglobalclass2
  42. {
  43.     public static class Group
  44.     {
  45.         static Person person;
  46.  
  47.         public static Person GlobalPerson
  48.         {
  49.             get { return person; }
  50.             set { person = value; }
  51.         }
  52.     }
  53. }
  54.  
  55.  
  56. //Program.cs
  57. ///*****************
  58. using System;
  59. using System.Collections.Generic;
  60. using System.Linq;
  61. using System.Text;
  62.  
  63. namespace testglobalclass2
  64. {
  65.     class Program
  66.     {
  67.         static void Main(string[] args)
  68.         {
  69.             Person gbPerson = new Person("Mister X");
  70.             Group.GlobalPerson = gbPerson;
  71.             string test = Group.GlobalPerson.Personname;
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment