Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace MyNamespace
- {
- class Program
- {
- struct MyStruct
- {
- public static int countOfCreatedObjects;
- public string name;
- }
- static void Main(string[] args)
- {
- MyStruct ms = new MyStruct();
- ms.name = "abc";
- MyStruct.countOfCreatedObjects = 1;
- MyStruct ms1 = new MyStruct();
- ms1.name = "xyz";
- MyStruct.countOfCreatedObjects++;
- MyStruct ms2 = new MyStruct();
- ms2.name = "abc";
- MyStruct.countOfCreatedObjects++;
- MyStruct ms3 = new MyStruct();
- ms3.name = "xyz";
- MyStruct.countOfCreatedObjects++;
- System.Console.WriteLine(MyStruct.countOfCreatedObjects);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement