public class ImmutableObject
      {
        private readonly string _name;
        public  Name => 
      
        public ( name)
        {
           = ;
        }
      }

      Csharp language logoCreates an immutable object

      C# recipes

      The ImmutableObject class has a private readonly string _name field. A public Name property is defined which takes a function that will be called when the object is set. This function will set the _name field to the object's current name.

      Shortcut: immutable

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.