Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Posts tagged c#

1 child tag

Use for questions dealing with C# ( a high level, statically typed, multi-paradigm programming language developed by Microsoft). C# code usually targets Microsoft's .NET family of tools and run-times, which include the .NET Framework, .NET Core and Xamarin among others.

This tag doesn't have a detailed wiki yet.

60%
+1 −0
Q&A Android CameraPreview not rendering for MLKit barcode analyis on MAUI custom control

I have a QR code which needs to read through Google's ML kit for Android since Zxing.MAUI doesnt read it. I followed the code in ml-kit/vision/barcode-scanning/android and VinayByte/mlkit-qr-code-s...

1 answer  ·  posted 3mo ago by carpeltunnel‭  ·  last activity 3mo ago by carpeltunnel‭

Question c# android mobile .net-maui
71%
+3 −0
Q&A Do Where and OfType preserve List capacity?

Unless I am mistaken, myList.Select(a => a).ToList() initializes the resulting list to the capacity of myList.Count. Does myList.Where(a => true).ToList() do so or does it build up from the i...

1 answer  ·  posted 7mo ago by LyndonGingerich‭  ·  last activity 7mo ago by rcmosher‭

Question c# linq iterable list
80%
+6 −0
Q&A C#: Performance hit from using calculated property instead of get-only property with initializer?

JetBrains Rider suggests that I change this (for example): public class Foo { public int OnePlusOne { get; } = 1 + 1; } to this: public class Foo { public int OnePlusOne => 1 + 1...

1 answer  ·  posted 8mo ago by LyndonGingerich‭  ·  last activity 7mo ago by Michael‭

Question c# attribute
71%
+3 −0
Q&A Unit Testing #define Directives in Visual Studio

I have some methods in my codebase that utilize the #if DEBUG preprocessor directive to provide specialized behavior that differs between the debugging environment and the production environment. I...

1 answer  ·  posted 8mo ago by Orladdin‭  ·  last activity 8mo ago by Olin Lathrop‭

Question c# visual-studio unit-testing
60%
+1 −0
Q&A Test Extension Method Received Call with NSubstitute

How can I verify that an extension method was called when using NSubstitute for unit testing? For a normal method I'd do something like: substitutedClass.Recieved().CheckedMethod(...) But exten...

1 answer  ·  posted 11mo ago by rcmosher‭  ·  last activity 11mo ago by rcmosher‭

Question c# nsubstitute
60%
+1 −0
Q&A Add an IDistributedCache to EntityFramework

Is there a standard way to add an IDistributedCached in front of a database using EntityFramework? Something that handles checking the cache for reads, updating the cache on writes, and uses distri...

0 answers  ·  posted 1y ago by rcmosher‭

Question c# entity-framework-core caching database
50%
+0 −0
Q&A Does Socket.AcceptAsync throw SocketException for any transient reason?

I'm writing exception handling around a call to Socket.AcceptAsync in a loop. One of the exceptions it's documented to throw is SocketException, but the documentation is vague: An error occurred...

1 answer  ·  posted 1y ago by Kevin Krumwiede‭  ·  last activity 1y ago by Alexei‭

Question c# sockets
66%
+2 −0
Q&A How to programmatically evaluate Excel data validations using .NET?

What I would like to do: Set a cell value. Check with a program if cell values conform to data validation rules. I could extract all the information needed to create a validation function, b...

1 answer  ·  posted 1y ago by toraritte‭  ·  last activity 1y ago by toraritte‭

Question c# f# excel
66%
+2 −0
Q&A Which .NET project can programmatically validate a cell's value out of the box based on Excel data validation constraints?

Are any of the popular Excel .NET projects have a functionality similar to Apache POI's DataValidationEvaluator class?

1 answer  ·  posted 1y ago by toraritte‭  ·  edited 1y ago by toraritte‭

Question c# f# excel Open-XML-SDK
75%
+4 −0
Q&A Is it possible to re-export types similar to JS?

I'm writing a library "MyLibrary". In there, I group code into sections that make sense. Let's say I have a folder "Reports" and a folder "Helpers". I would like to have my code separated while ...

1 answer  ·  posted 1y ago by raphaelschmitz‭  ·  last activity 1y ago by raphaelschmitz‭

Question c#
66%
+2 −0
Q&A Winui 3 Combobox in datagrid not displaying data

I am migrating a WPF app to WinUI3. Things went well until I needed to put a combo box in the datagrid. That MS had removed the datagrid from the standard tools was overcome with Community Toolkit ...

0 answers  ·  posted 1y ago by FrankLuke‭

Question c# wpf
35%
+4 −9
Q&A Find the name of the student with the top mark, display their name and mark

I have a CSV file like this: name,surname,score Moon,Walko,148 Jerald,Gryder,150 I need to find the highest score. My attempt: namespace test { class Program { string[...

2 answers  ·  posted 4y ago by InPut‭  ·  last activity 1y ago by NetMage‭

Question c# csv
66%
+2 −0
Q&A How can I return XML from BeforeSendRequest and AfterReceiveReply to the calling method in a thread-safe way?

We have a console application using the Azure WebJob SDK. The WebJob relies on a WCF service using SOAP, which it accesses through a DLL we wrote that wraps the auto-generated WCF types in somethin...

1 answer  ·  posted 2y ago by Celarix‭  ·  edited 2y ago by Alexei‭

Question c# wcf thread-safety azure-webjobs
86%
+11 −0
Q&A When would one not want to return an interface?

Consider the following method as an example: List<int> Foo() { // ... } Are there any disadvantages of returning an interface instead of a concrete implementation in C#? IList<i...

3 answers  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by matthewsnyder‭

Question c# concrete-type interface-type
77%
+5 −0
Q&A Library that is platform-specific via selective compilation?

The proposed library would sit alongside cross-platform libraries in Xamarin apps for iOS and Android. However, it would include files with names like MyLibraryFile.android.cs MyLibraryFile.ios...

1 answer  ·  posted 2y ago by plod‭  ·  last activity 2y ago by Olin Lathrop‭

Question c# cross-platform
71%
+3 −0
Q&A Updating the database reverses previous changes

The Code using Microsoft.EntityFrameworkCore; public class BloggingContext : DbContext { public DbSet<Blog> Blogs { get; set; } public DbSet<Post> Posts { get; set; } ...

2 answers  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by FoggyFinder‭

Question c# entity-framework-core sqlite
60%
+1 −0
Q&A Datagrid in MVVM saves edits but not inserts

I am writing a todolist application in WPF with MVVM. I display the goals in a datagrid and the editing works fine. Changes made in the grid are saved to the DB when I click save. However, adding a...

1 answer  ·  posted 2y ago by FrankLuke‭  ·  last activity 2y ago by Alexei‭

Question c# mvvm wpf
50%
+0 −0
Q&A How to define Polly policies when working with Refit library in ASP.NET Core?

Note: this is based on my question on SO and subsequent activity there I am trying to add resilience using Polly to HTTP calls that are performed using Refit library. I am using the Refit factory...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Alexei‭

Question c# asp.net-core refit polly
60%
+1 −0
Q&A How to refer to the same class twice from one Entity Framework entity?

I have two classes, Contestant and Picture, with the following setup: public class Contestant { ... public int AvatarID { get; set; } [ForeignKey(nameof(AvatarID))] public ...

1 answer  ·  posted 2y ago by FrankLuke‭  ·  edited 2y ago by Alexei‭

Question c# entity-framework-core navigation-properties
42%
+1 −2
Q&A How to generate random objects at different locations on x, y, z axis

I have been trying to generate a random object on all three axis in different locations. However, Vector3 doesn't accept that many overloads e.g: Vector3 spawnPos = new Vector3(Random.Range(spawnL...

1 answer  ·  posted 2y ago by simonJN‭  ·  last activity 2y ago by deleted user

Question c# unity3d
50%
+0 −0
Q&A Working with a generic class that uses a type that should be of generic type

I have followed Nick Chapsas' tutorial to avoid throwing a ValidationException to treat validation errors and instead rely on LanguageExt.Common.Result<> from LanguageExt library. I have ma...

0 answers  ·  posted 3y ago by Alexei‭

Question c# generics .net .net-6
66%
+2 −0
Q&A C# WPF datagrid not persisting inserts

I am working with VS 2022 and trying to make a WPF MVVM application. The application updates the items displayed in the datagrid, persisting the changes to the database upon save. However, adding a...

0 answers  ·  posted 3y ago by FrankLuke‭

Question c# entity-framework-core mvvm wpf
75%
+4 −0
Q&A WPF MVVM ListBox not updating

I am trying to combine MVVM in WPF using Microsoft.Toolkit.MVVM. Somethings are working as expected. The text boxes bind to fields and update in both directions. The button command executes and cha...

2 answers  ·  posted 3y ago by FrankLuke‭  ·  last activity 3y ago by elgonzo‭

Question c# binding mvvm wpf
75%
+4 −0
Code Reviews Measuring arithmetic overflow checking overhead in C#

Overflow checking for integral-type arithmetic operations is disabled by default and it can be explicitly enabled by using using checked function or the -checked compiler switch. Since I mainly de...

2 answers  ·  posted 3y ago by Alexei‭  ·  last activity 3y ago by Derek Elkins‭

Question c# benchmarking
66%
+2 −0
Q&A What are the drawbacks of using data snapshot testing?

Our team is finally focusing on writing more automatic testing and one of my ex-colleagues recommended to try out the Verify library. The tool does the following: runs the test and compares the...

1 answer  ·  posted 3y ago by Alexei‭  ·  last activity 3y ago by Derek Elkins‭

Question c# snapshot-testing verify-tests
71%
+3 −0
Q&A Why static code analyzers such as SonarQube indicate a high code complexity for switch statements?

During a presentation of a pipeline configuration, a colleague showed a SonarQube integration and one of its reports. A warning was caused by overrunning the max value for the code complexity thres...

2 answers  ·  posted 3y ago by Alexei‭  ·  last activity 3y ago by Derek Elkins‭

Question c# static-code-analysis cyclomatic-complexity
77%
+5 −0
Q&A How to dynamically change panel of ItemsControl?

Let's say I have some collection of data. My goal is to provide different kind of view of ItemsControl depending on user`s preference. For simplicity, we can assume that user can select only betwe...

1 answer  ·  posted 3y ago by FoggyFinder‭  ·  edited 3y ago by FoggyFinder‭

Question c# .net mvvm avalonia
75%
+4 −0
Q&A Get the length of a slice from a multi-dimensional array

If I have a one-dimensional array, I can get the length of it quite easily: var x = moves.Length(). However, if the array is multi-dimensional, .Length() returns the total number of elements. If ...

2 answers  ·  posted 3y ago by FrankLuke‭  ·  last activity 3y ago by FoggyFinder‭

Question c# array multidimensional-array
71%
+3 −0
Q&A Credentials for multiple tenants with Azure.Identity

Situation: I have an Azure account which has management permissions for various subscriptions in various directories (tenants). I have a GUI tool to do various management tasks whose details are ir...

0 answers  ·  posted 3y ago by Peter Taylor‭

Question c# authentication azure
71%
+3 −0
Q&A How do I redact values when Save()ing a yaml structure with YamlDotNet?

I handle several projects that use yaml files for configuration, and load them with YamlDotNet. It is sometimes useful to log the effective configuration when the program starts, to aid future debu...

0 answers  ·  posted 4y ago by ajv‭  ·  edited 4y ago by Troy‭

Question c# .net yaml yamldotnet
60%
+1 −0
Q&A Saving modified data in gridview on clicking SaveButton

I am struggling to do a save button in C# Windows Form Application where I have a GridView and I want to save all modifications I do in GridView Table(I connected it to SQL). This is the data sourc...

1 answer  ·  posted 4y ago by Cri‭  ·  edited 4y ago by Alexei‭

Question c# winforms gridview
75%
+4 −0
Q&A How to generate multi-line completions (code generation) with OpenAI?

I have finally received access to a trial account on OpenAI and I took it for a spin. My interest is with code generation, so first tried something simple using the playground: Q: generate a stand...

1 answer  ·  posted 4y ago by Alexei‭  ·  edited 4y ago by deleted user

Question c# openai code-generation gpt-3
50%
+1 −1
Q&A Why are my EMA values ​​different from the ones on the website? [closed]

I wrote a program for calculating EMA, but my values ​​differ from the values ​​calculated on this site. My program: double[] x = Numbers();//array numbers int N = 5; double k = 2.0 / (N + 1...

0 answers  ·  posted 4y ago by kolaa‭  ·  closed 4y ago by Alexei‭

Question c# .net-core
83%
+8 −0
Q&A Update list based on presence of identifier in a second list

In C#, I have two lists and need to mark records in the first based on the second. Here's a sample: public class Vehicle { public string Make { get; set; } public string VIN { get; set;...

3 answers  ·  posted 4y ago by FrankLuke‭  ·  last activity 4y ago by Andrew Shepherd‭

Question c# linq
77%
+5 −0
Q&A F-bounded polymorphism, interface operators, and type inference in C#

C# language version 8.0 introduces limited support for static methods, operators, etc. in interfaces. However, there are still limitations. I was hoping to use the new language features to try a ge...

0 answers  ·  posted 4y ago by Peter Taylor‭

Question c# polymorphism type-system operator-overloading
75%
+4 −0
Q&A Declaring interface members with generic return types: "The type parameter [generic type] cannot be used with type arguments"

I'm trying to write an interface to define the set of operations I expect my repositories' Unit of Work implementations to have, and I want this interface to be fulfilled by EF Core's DbContext cla...

2 answers  ·  posted 4y ago by Marc.2377‭  ·  last activity 4y ago by Marc.2377‭

Question c# generics .net interface .net-core
66%
+2 −0
Code Reviews C# WPF MVVM View & Get new record values

Just looking to hear some reviews on my current MVVM Implementation, If I am heading towards the right direction. :) Code BaseViewModel public class BaseViewModel : INotifyPropertyChanged { ...

1 answer  ·  posted 4y ago by gzi98‭  ·  last activity 4y ago by FoggyFinder‭

Question c# mvvm wpf
57%
+2 −1
Q&A How to filter data from the view using MVVM Pattern?

I am trying to filter data in the DataGrid using the texboxes using the MVVM pattern. Just not sure how to do it. Would appreciate any guidance. My current code: Model public class Technical_Bes...

1 answer  ·  posted 4y ago by gzi98‭  ·  last activity 4y ago by FoggyFinder‭

Question c# mvvm wpf
80%
+6 −0
Code Reviews C# MVVM Login Project

I was wondering if somebody can review my code? I am creating a simple login desktop application, just to get used to the MVVM pattern using WPF. View <Window x:Class="Login_App.MainWindow" ...

2 answers  ·  posted 4y ago by gzi98‭  ·  last activity 4y ago by Peter Taylor‭

Question c# mvvm wpf
72%
+6 −1
Q&A Which abstraction should I choose for background services and why?

Which concept is best for managed background services? 1. RunAsync(CancellationToken): interface IWorker { Task RunAsync(CancellationToken cancellationToken = default); } ... IWorker worker =...

1 answer  ·  posted 4y ago by Kir_Antipov‭  ·  last activity 4y ago by Alexei‭

Question c# software-practices async-await .net
60%
+1 −0
Code Reviews Cache data using Redis Cache in an ASP.NET Core 3.1 project

This is an unanswered code review request of mine from Code Review Stack Exchange. Overview I have developed a small ASP.NET Core 3.1 Web API that provides information that is rarely changed (sever...

0 answers  ·  posted 4y ago by Alexei‭

Question c# asp.net-core asp.net-core-3.1 caching redis
66%
+2 −0
Code Reviews Measure ASP.NET Core 3.1 Web API action execution times

This is basically an unanswered code review request of mine from CodeReview Stack Exchange. I want to be able to log as accurately as possible, the time spent by a certain Web API action in an ASP....

0 answers  ·  posted 4y ago by Alexei‭

Question c# asp.net-core-3.1 performance
66%
+2 −0
Q&A How to perform LINQ joins with multiple fields in a single join?

Note: this is an aggregate of the answer provided for this question. I want to get the LINQ equivalent of the following from SQL: SELECT .. FROM entity1 e1 JOIN entity2 e2 ON e1.field1 = e2.fie...

1 answer  ·  posted 4y ago by Alexei‭  ·  last activity 4y ago by Alexei‭

Question c# linq join
80%
+6 −0
Q&A Is it recommended for ASP.NET Web API actions to always include a CancellationToken?

Note: This is basically a question from Stack Overflow that was closed for a very long period of time and I fear it might get closed again as primarily opinion based. I am wondering if my ASP.NET C...

1 answer  ·  posted 4y ago by Alexei‭  ·  last activity 4y ago by Peter Taylor‭

Question c# asp.net-core software-practices asp.net-core-webapi cancellation-token