What does ":this(100)" mean in a C# method declaration? -


this question has answer here:

what ":this(100)" mean in c# method declaration?

while reading mdsn docs came across in line 6 of following code:

  public class stack     {        readonly int m_size;         int m_stackpointer = 0;        object[] m_items;         public stack():this(100)        {}           public stack(int size)        {           m_size = size;           m_items = new object[m_size];        }     } 

public stack() 

is default constructor

public stack(int size) 

is parametric constructor

public stack():this(100) 

means default constructor call parametric constructor parameter size 100.

refer this construtor more information

this used in constructors. used overload constructors in c# program. allows code shared between constructors. constructor initializers, use this-keyword, prove useful in nontrivial classes.


Comments

Popular posts from this blog

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

Qt4: how to send QString inside a struct via QSharedMemory -