199
Console.WriteLine("Public Constructor of SuperAdmin class is called. Which initiate the constructor chaining.");
1
// Author : Tech Point Fundamentals
2
// Website : www.techpointfunda.com
3
// Demo : Constructors in C#
4
5
using System;
6
7
public class Program
8
{
9
10
public static void Main()
11
{
12
Console.WriteLine("\n--------- Default Constructor --------- ");
13
var _userDefault = new User();
14
Console.WriteLine("UserName : " + _userDefault.UserName);
15
Console.WriteLine("Password : " + _userDefault.Password);
16
17
Console.WriteLine("\n\n--------- Parameterized Constructor --------- ");
18
var _userParameterized = new User("TechPoint", "********");
19
Console.WriteLine("UserName : " + _userParameterized.UserName);
20
Console.WriteLine("Password : " + _userParameterized.Password);
21
22
Console.WriteLine("\n\n--------- Copy Constructor --------- ");
23
var _userCopy = new User(_userParameterized);
24
Console.WriteLine("UserName : " + _userCopy.UserName);
Cached Result
Compilation error (line 11, col 7): Operator '==' cannot be applied to operands of type 'int' and 'string'