Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
47 views

I was following a video to create small Visual Studio project for an alternate data entry. The video tutorial was on Visual Studio 2019 Blazor project and I'm on 2022 - so some slight variation. Code ...
user avatar
0 votes
1 answer
63 views

I saw in Microsoft learn site here option of use primary constractor body with this example: public class C(int i, string s) : B(s) { { if (i < 0) throw new ArgumentOutOfRangeException(...
אפרת's user avatar
0 votes
1 answer
207 views

I was having a azure function and it's working fine and I have changed that to primary constructor and it's working perfectly fine on my local envrionment but while deploying that using the az ...
Imran Ahmad Shahid's user avatar
0 votes
1 answer
131 views

IDE0290 suggests the use of primary constructors, but if one of the parameters happens to a IDisposable injected and you use readonly backup fields to store them, a CA2213 warning is generated public ...
Vincent Ripoll's user avatar
0 votes
2 answers
296 views

In C# now (I'm not certain when this was added to the spec) we can declare a class without a body: public class MyClass; If I create an instance, though, I can't do anything with it. I thought it ...
rory.ap's user avatar
  • 35.7k
10 votes
1 answer
6k views

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) ...
Mario Vernari's user avatar
0 votes
1 answer
445 views

Problem When creating a class with a primary constructor, the quick actions for adding another parameter in the constructor do not work as expected. The actual assignment of the constructor parameter ...
NTE's user avatar
  • 53
30 votes
4 answers
8k views

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 own ...
me.at.coding's user avatar
  • 18.5k
5 votes
1 answer
3k views

I'm updating my code to C# 12 and one aspect is to use primary constructors where it makes sense. One place that's giving me a bit of a struggle is inside a ref struct which takes a ReadOnlySpan as a ...
Steven Liekens's user avatar
30 votes
4 answers
6k views

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 ...
Milad Ahmadi's user avatar
2 votes
1 answer
759 views

I don't know how to make it so that when creating an object the values of the parameters "pass through the setters" the closest I've gotten is to duplicate the code, use once in the creation ...
Antonio SPR's user avatar
1 vote
1 answer
132 views

I am trying to assign data to my class using the variable that I created. I want to use the variable as an instance of the membership class. Every time I pass any values I get an error. error: no ...
ja233's user avatar
  • 23
3 votes
1 answer
260 views

Diamond problem is handled in some OOPS languages (eg. curl) by having the repeatedly inherited class as "shared"? I want to know how this works. Also, I want to know the role played by primary and ...
Kamalapriya Subramanian's user avatar
0 votes
1 answer
502 views

I am learning Kotlin and I'm kind of stuck with the constructors. I've written a program to help me understand the concept. The program is as follows: open class Animal(){ var name :String = "...
rdias002's user avatar
  • 234
11 votes
2 answers
2k views

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 classes ...
David Pfeffer's user avatar