Declaration Read only property with initialization - CSharp Custom Type

CSharp examples for Custom Type:read only

Description

Declaration Read only property with initialization

Demo Code

using System.Collections.Generic;
using System;//from www  . j  a va2s.  com
using System.ComponentModel;
public class Person
{
    public List<Person> Friends { get; } = new List<Person>();
}
class MainClass
{
    static void Main()
    {
        Person p = new Person();
        Console.WriteLine(p.Friends.Capacity);
    }
}

Result


Related Tutorials