What does ":this(100)" mean in a C# method declaration? -
this question has answer here:
- what colon (:) mean? 7 answers
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
Post a Comment