How to Use Expression in Constructor Parameter?
- Last UpdatedJun 10, 2024
- 1 minute read
This example shows how to pass expression as parameter to the constructor parameter.
.ctor (int EmployeeID, string EmployeeName, string Department, string Designation, int Age, double Salary)
The above constructor takes 6 parameters.
Constructor parameters can be passed like this.
.ctor (5, "ABC" + "XYZ", "R & D", "Analyst", 30, 50000)
Here, the second parameter is passed as the expression: "ABC" + "XYZ" which is evaluated at the time of execution and updated with the value "ABCXYZ."
