Questions tagged [c#]

C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform. Use this tag for questions related to C#. In case a specific version of the framework is used, you could also include that tag; for instance .net-2.0.

Filter by
Sorted by
Tagged with
2
votes
1answer
71 views

C# Password Security Login System with SQLite

I want to start by just mentioning I'm a semi-beginner at C# and cyber security so any feedback is appreciated :) What I think I need reviewing is the SQLite queries and maybe the hashing functions I'...
-1
votes
0answers
18 views

GUID Usage Suggestion

I am building an education website where: A student (I will call him/her a user) goes to an "educational center" then pay money for a "Attempt code" (From 5 to 8 digits "...
-1
votes
0answers
34 views

Temporarily halt app processing loop when computer suspended [closed]

My fully async long-running console app intermittently enters a coma after my computer wakes from sleep/hibernation. I'm no expert but it seems like async IO callbacks are getting dropped or something....
0
votes
1answer
43 views

Create a method in a Cosmos service that runs a LINQ lambda passed as parameter

I'm creating a Cosmos service, it has basic CRUD but I want to implement one method that receiving an expression with LINQ executes it against the DB. I have this: ...
-3
votes
0answers
32 views

Read a file txt and calculate the average of students grades in C# [closed]

Good morning, I'm trying to build a program in C # that will read the highest grades from a file called Grades.txt in the first step and save it in another file called Bestgrades.txt, in the second ...
-1
votes
0answers
42 views

My code feels clumsy. What would be the better solution? [closed]

I have initials, surname prefix and surname. If initials are not available I don't want an extra space in the concatenation of the abovementioned. So I've done this. But it feels clumsy. Hence my ...
0
votes
0answers
49 views

Trying to replace ManagementEventWatcher class in System.Management

I am working on replacing a dependency in a library for System.Management and migrating to using Microsoft.Management.Infrastructure as recommended by Microsoft. The issue is that Microsoft.Management....
2
votes
1answer
47 views

Factory Method and Log writer class

I Have this class want to practice how to write a factory method pattern and I can change the logPlace by set the app.config, and I try to improve the performance ...
3
votes
1answer
63 views

Is this usage of the dynamic keyword an indicator of a design fault?

I feel like I'm likely violating a design principal or two here so I'd appreciate any mistakes or antipatterns being named and pointed out. I'm attempting to map a system in code which represents a ...
1
vote
1answer
81 views

A Generic Two Dimensional Data Plane with SubPlane Method in C#

This is a follow-up question for Generic Two Dimensional Data Plane with Manipulation Methods For C# and A SubPlane Method for Generic Two Dimensional Data Plane in C#. Based on iSR5's suggestion, in <...
7
votes
2answers
74 views

Method to randomise a string's case

I'm an amateur at programming and have created the following method with which I pass a lowercase string with the idea it is then returned either in it's original ...
0
votes
1answer
44 views

How to make this code follow Solid Principle C# [closed]

Currently I have this code: ...
3
votes
1answer
69 views

Applying 'Uncle Bob's Clean Code' on this small exercice

I'm trying to apply Uncle Bob's Clean Code practices onto this exercise I'm helping someone with. (The exercise assignment is in a "docstring" comment above the ...
0
votes
1answer
48 views

Methods improvements

I just recently learned how to write Methods in C#. Here is one experiment I made. It calculates addition, subtraction, division, multiplication, and the square root of a number. fill free to give me ...
0
votes
2answers
49 views

Generating a random directed graph

I wrote a function that returns a directed graph as an adjacency matrix. The function requires two arguments: the amount of nodes and the amount of edges. At first, nodes are placed and instantly ...
3
votes
1answer
67 views

Namespace list to directory structure

Namespace list to directory structure Motivation I have a list of namespaces I extracted from types, and I which to create a directory structure, that represents these namespaces. So that I can place ...
3
votes
1answer
66 views

Calculating n-ary Cartesian Product too slow

The method gets called extensively throughout my programm, is there any way I can speed it up or improve other aspects? The code calculates the n-ary Cartesian Product of a List containing n Lists, ...
2
votes
2answers
71 views

Replace string based on multiple rules, don't replace same section twice

Given a 2-column CSV dictionary file that contains translation of certain words, this c# code needs to replace the first occurrence of a word in the dictionary. Once a segment of string has been ...
1
vote
2answers
49 views

ASP.NET Core singleton with a thread-safe property that can be changed

Thanks to ASP.NET Core dependency injection, there's no need to follow the Singleton pattern; any class will do. What I want to do is to have a class that will store a value that'll be used by another ...
4
votes
2answers
98 views

My first ever calculator C# [duplicate]

This is my first ever created program I've made. It's not very good but I'm pretty proud of it. If you have any suggestions I could add into the calculator I would gladly do that. ...
1
vote
1answer
99 views

How can I speed up the processing of the received channel socket

This currently runs with 1400+ sockets and manages data correctly and in the manner the application requires. I do have an issue with the HandleData method where ...
0
votes
1answer
64 views

Random Cave Generator Design Feedback

I am looking for feedback on my code's overall structure and design. I made a few concessions in reusability for the sake of not overcomplicating things (static/const public variables in the Game1 ...
1
vote
1answer
90 views

A Tiny Text File Read/Write class Implementation in C#

I am trying to implement a tiny text file read / write class FileIO in order to make the operations of reading / writing pure text files easily. The usage is like: <...
-1
votes
0answers
39 views

Simple game on Unity with bad code

I am a beginner to programming and I have created some simple game using Unity. The code spawns some 2d balls and player taps on the balls. I know, that my code is very bad, but I don't know what kind ...
2
votes
0answers
57 views

Visitor pattern, Extensible visitor for custom implementation

I'm writing my own expression tree system, just for fun, but I have a few doubts about my code. My goal here is to create an abstract layer of expressions, and allow different "languages" to ...
1
vote
1answer
64 views

Builiding a Model from Stored Procedures

After reading that Data Classes can be considered a code smell, I am shifting from a pattern with many data classes and a single manager class that handles all the instantiation of the classes, to a ...
2
votes
2answers
142 views

Calculator Program improvements

I'm pretty new to programming and made a few programs so far. I recently made a Calculator program and I hope you guys could tell me what I could do to improve. ...
0
votes
1answer
78 views

Is this enough for unit testing a basic controller?

My pet project, is a community driven lyrics archive, it is still a work in progress, and all code is open sourced on GitHub. I have a local git branch ...
1
vote
2answers
72 views

Finding duplicates in multiple lists for configuration validation

I have created helper class for configuration validation, the main purpose is to find any human "errors" in the configuration for the app. the case is that any type of "message" ...
5
votes
2answers
113 views

Sobel Operator - SIMD x86 Intrinsics Implementation

I'm learning C# .NET 5 Intrinsics and interested in best practices. It's really hard now to find enough information about how SIMD instructions (logically/internally) work in .NET. In addition i'm not ...
2
votes
2answers
78 views

A Sub-string Extractor with Specific Keywords Parameter Implementation in C#

I am trying to implement a sub-string extractor with "start keyword" and "end keyword" and the extracted result is from (but excluded) the given start keyword to (but excluded) end ...
0
votes
1answer
68 views
6
votes
2answers
57 views

Simple 5 operator calculator in C#

The program takes 2 decimals as input and an operator (+, -, *, /, ^) so far. Any suggestions to make this code cleaner or shorter? ...
2
votes
1answer
57 views

Text-based console game

I'm currently learning C# in hopes of making games on my own using Unity. I'm using the Udemy class by Denis Panjuta and followed 8 sections before making my first app by myself. The 8 sections ...
0
votes
2answers
59 views

Nested foreach loop returning modified list

In this method, I was tasked to take in a list of TemplateMap and attach dynamic parameters and in a certain case, add further templates to the returned list. This ...
2
votes
2answers
73 views

API response json to C# object

So I got kind of a weird format returned from the api I'm calling it's the following: ...
2
votes
3answers
72 views

C# Asp.net core middleware for redirecting URLs

I wrote a small middleware for redirecting between WWW URLs. The most important thing that I want to change is to make it super fast. Here's what it is doing: If the host is localhost or mywebsite.com ...
-1
votes
1answer
80 views

Simplifying for loops that includes conditions with better linq queries

The code below selects all items that are locked. How can I optimise it? ShopItemData doesn't contain a field for locked/unlocked. ...
0
votes
0answers
57 views

Creating a deck for a card game

Some friends and I were playing the game Spot It, which has x cards each with y symbols on them, from a potential of ...
5
votes
1answer
108 views

Optimizing Matrix class with less calls to new

I'm designing a Matrix class and I feel like what I've come up with requires too many calls to new. I know it's possible that caring about this is premature, but I ...
0
votes
1answer
43 views

Unity C# - Radar works but performance is horrible (Update & LateUpdate)

Hello I need help to optimize this code. I have a radar and it gets the enemies from a list and adds an image to their location to track them. I use Update to remove the images and LateUpdate to add ...
6
votes
3answers
558 views

A program that uses three methods to reverse and print an array

I have this code that uses three methods to do certain tasks. One creates an array, another reverses it and the other one prints it out(it was required to use three methods). A person recommended me ...
2
votes
1answer
60 views

Simplifying these methods for iterating through object and modifying string fields

I have this method (consisting of three methods) that I need to use for looking through objects that are going to be serializes and logged as json objects. a bit of intro (not necessary to read) The ...
2
votes
2answers
100 views

final code of my first winform application

I am learning .NET for about a month now ..and i am practicing by making a simple WinForms project ..now almost my WinForms is completed ..i need to gather your suggestion on how my progress is going ...
0
votes
2answers
90 views

Optimizing database access using LINQ [closed]

I have the following method that I am trying to optimize. Currently, the method works great, however, it takes a little over 3 hours to complete. I feel like, using some nifty LINQ joins, it should be ...
1
vote
1answer
88 views

Allow adding errors and warnings and remove both after a while with seperate timers

I use this in my Blazor application, letting other services send errors or warnings to this AlertService. The service triggers an update of a component which simply displays the messages, errors in ...
2
votes
0answers
70 views

Find the largest contiguous sum of two or more integers in an array of positive or negative integers?

I received an interview question: Find the largest contiguous sum of two or more integers in an array of positive or negative integers. I wrote a brute force solution, which is slow at O(n^2). Is ...
0
votes
1answer
41 views

Unity Static Singleton JSON Serialisation

I have a static PlayerData singleton which stores all the data for the player (gold, upgrades, heroes etc) but JsonUtility ...
4
votes
1answer
61 views

Minimum number of copies of an application a company needs to purchase

Some applications from vendors are allowed to be installed on multiple computers per user with specific restrictions. In our scenario, each copy of the application (ID 374) allows the user to install ...
2
votes
0answers
73 views

C# Learning MVVM by creating a Login functionality

I am trying to get my head around how MVVM pattern works. Would like to hear some reviews if I am implementing it correctly. View ...

1
2 3 4 5
189