Skip to main content

Questions tagged [c#]

C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform

Filter by
Sorted by
Tagged with
4 votes
1 answer
111 views

I'm working on a WPF application which has many user interactions which start with opening a non model window, allowing some interaction with the window and the rest of the application (think ...
LOul's user avatar
  • 41
2 votes
2 answers
308 views

I’m working on a WPF MVVM application that has grown beyond just one or two User Controls. I now have multiple ViewModels that need to react to each other’s actions (e.g., selecting a customer in one ...
Sam's user avatar
  • 29
8 votes
4 answers
2k views

When using Entity Framework and running the Update-Database command, non-updated applications that rely on the database crash due to database context changes. Usually teams have a production database ...
EMN's user avatar
  • 795
4 votes
1 answer
1k views

My job uses SonarQube as part of the CI/CD quality gate. One of the "Maintainability" issues (severity: medium) raised is the CA-1822: Mark members as static. The link explains the added ...
Veverke's user avatar
  • 541
1 vote
3 answers
245 views

I have a C# library that contains all the logic to send requests to a remote endpoint, including marshalling/unmarshalling and encrypting/decrypting requests and responses. It contains an HttpClient ...
hyt's user avatar
  • 121
0 votes
2 answers
150 views

When using recursion in an extension method, there are two different ways to invoke the method from within itself. Option 1: As an extension method internal static class MyExtension { public ...
Josh Brunton's user avatar
16 votes
10 answers
5k views

I have noticed in documentation, looking at open-source code bases, and just a general sense in the industry that C# developers largely prefer to use List<> or IEnumerable<> over simple ...
K0D4's user avatar
  • 423
2 votes
3 answers
171 views

My team does predominantly back-end work in C#, with a smattering of front-end web development using Angular. We're starting a new website project, based on the Admin LTE framework / template. This is ...
mmathis's user avatar
  • 5,586
0 votes
2 answers
346 views

I have a question about setting up my service. My main concern is if the design is clean and in order. Whether it meets the SOLID principles and does not spill out on me. I have entities like order ...
Petr Klekner's user avatar
3 votes
1 answer
164 views

The move to MVC and MVVM has not been easy for me. Combining multiple languages in single pages with inline code is something I find disorienting. I'd like to remedy this by attempting to use Razor ...
Northern Scrub's user avatar
2 votes
1 answer
180 views

Preface: This will not be available publicly or to third parties, so I am not concerned about users having the background knowledge to properly form GET requests. These are also not only analytical ...
user avatar
1 vote
1 answer
321 views

public void ReassignLineItems(InvoiceUpdateDto invoiceUpdate) { Invoice invoiceInRepository = _unitOfWork.InvoiceRepository .FirstOrDefault(invoice => invoice.Id == invoiceUpdate.Id); ...
EMN's user avatar
  • 795
2 votes
1 answer
145 views

My main focus is having as little duplicate code/files as possible. Most of the HTML I write is almost identical. There is already a form template which holds the form and several necessities. That ...
Roe's user avatar
  • 131
1 vote
1 answer
176 views

In an ASP.NET MVC application with views that make AJAX calls for widgets like dropdowns and data grids, is it better to use Web API controllers or regular MVC action methods that return JSON? The ...
EMN's user avatar
  • 795
0 votes
2 answers
239 views

I am new to C#, and Windows (coming from Python, Linux background). I need to add tests to an existing C# codebase, which relies on a MSSQL database and Entity Framework. In my old days when testing ...
mguijarr's user avatar
  • 226
1 vote
3 answers
519 views

As we know, there are (at least) four ways to instantiate a class object in C#. But I've never quite understood why some ways are better than others. First of all, you can explicitly declare the ...
Cade Bryant's user avatar
1 vote
3 answers
190 views

I am developing some modular libraries that contain common APIs, data, and functionality. One of the core assumptions to these libraries is you would use which you want to compose your project, but ...
SventoryMang's user avatar
4 votes
4 answers
474 views

Microsoft identifies dependency injection as one of the uses for primary constructors. public class ExampleController(IService service) : ControllerBase { [HttpGet] public ActionResult<...
Jannick Breunis's user avatar
0 votes
4 answers
282 views

So I just learned about Expression<TDelegate>. As a library author this really intrigued me; my libraries make extensive use of source generators to generate both high-performance code and code ...
Applekini's user avatar
  • 117
1 vote
1 answer
179 views

What are the use cases of TestOf? I'm new to NUnit testing and from what I have seen, most people don't use this attribute that much. From my experience, TestOf helped me to quickly identify what ...
LNTR's user avatar
  • 43
17 votes
5 answers
3k views

I'm unsure whether parameter names should describe their object types or if shorter, more concise names are preferable. Consider the following two method signatures: public void PrintPoint(...
Abcd's user avatar
  • 297
3 votes
3 answers
979 views

I am designing a fluent builder pattern API that branches and allows different options based on what has already been called. For example: Build().Foo().Bar() is valid code, but Build().Baz().Bar() ...
starikcetin's user avatar