Advertisement
Dr_Max_Experience

static member

Jan 29th, 2022
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ООП
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             User user1 = new User();
  10.             User user2 = new User();
  11.  
  12.             Console.WriteLine(user1.Id);
  13.             Console.WriteLine(user2.Id);
  14.         }
  15.     }
  16.  
  17.     class User
  18.     {
  19.         public static int Ids;
  20.         public int Id;
  21.  
  22.         public User()
  23.         {
  24.             Id = ++Ids;
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement