primary-constructor Questions
4
I am not so happy with primary constructors - because the constructor parameters are not readonly, it's too error prone in my opinion, especially when working with base classes which receive their ...
Incurrence asked 24/1, 2024 at 11:39
1
Solved
I noticed that a snippet like the below one, it marks the property initialization with a warning.
public sealed class C(int a)
{
public int A { get; } = a; //<--here
public int Sum(int b)
{
...
Tobit asked 12/3, 2024 at 13:35
2
Solved
I'm using C# 12. In C# 12 I can use primary constructor:
Implementation 1 :
public class Calculation(int a,int b)
{
public int Addition() => a + b;
public int Subtraction() => a - b;
}
Imp...
Lunation asked 6/12, 2023 at 9:48
3
Solved
I using C# 12.
In C# 12 I can use primary constructor:
public class UserService(IUnitOfWork uow) : IUserService
{
}
Before C# 12 I used null checking for items that I inject in constructor:
public...
Utopian asked 27/11, 2023 at 11:13
2
Why do primary constructors in C# 12 do execute in opposite order?
That's kind of a breaking change to say the least...
Example:
namespace Whatever;
[TestClass]
public class UnitTestTemp
{
[TestM...
Dismuke asked 2/12, 2023 at 10:32
3
Kotlin has two types of constructors, primary and secondary. What is the purpose of having two types? In my opinion it makes the code more complicated and inconsistent. If both types of constructor...
Domingadomingo asked 26/7, 2018 at 14:57
2
Solved
The C# 6 preview for Visual Studio 2013 supported a primary constructors feature that the team has decided will not make it into the final release. Unfortunately, my team implemented over 200 class...
Vola asked 12/12, 2014 at 18:29
1
© 2022 - 2025 — McMap. All rights reserved.