Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Internal in C#

Since the both classes (Program1 and Program2) are in the same project, it is legal to use internal keyword for accessing.

  1. using System;
  2. using System.IO;
  3.  
  4. namespace forgetCode
  5. {
  6. class program1
  7. {
  8. static void Main(string[] args)
  9. {
  10. program2 obj = new program2();
  11. string new_name = obj.name;
  12. Console.WriteLine(new_name);
  13.  
  14. }
  15. }
  16.  
  17. class program2
  18. {
  19. internal string name = "Forget Code";
  20. }
  21. }


Output:
Forget Code

..