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

learn more… | top users | synonyms

0
votes
0answers
77 views

Entity Framework responding to requests

My WebAPI code is hosted on a GoDaddy server. I have 2 issues: The action method returns a response after 35 seconds for the first call after the code is updated on the server. From this issue, I ...
-1
votes
0answers
8 views

Start (and Join) a Thread Inside a Task? [on hold]

My AWS server is currently not preforming very well. I'm building a REST service that uses the async-await pattern to keep everything running smoothly. I use a ...
3
votes
1answer
43 views

Two-player number guessing game

I created a 2-player number guessing game. Each player picks a number between 1 and 10 and closes one wins. I'm just looking for best practices suggestions and improvements. Console program.cs ...
7
votes
6answers
230 views

Numbers to byte-arrays and back

As the title explains, this is a series of extension methods that convert certain numeric types to and from byte-arrays, for certain actions which work better on byte-array types than numeric types. ...
2
votes
1answer
21 views

A set of Razor HTML helpers for disabling elements

I am developing a huge form with a lot of elements in it. The purpose of this form is editing one domain entity. Now, I finished developing the whole form and it just shows the bunch of text boxes, ...
1
vote
1answer
40 views

RadioButton Selection Extremely Slow

I have a DataGrid that I filter when the user inputs text into a search box. The column that is filtered is based upon which radio button the user selects (Name, Town or Post Code). Although initially ...
1
vote
0answers
33 views

Eliminate code duplication for copying properties between two classes

I have an ASP.NET MVC 5 app and I map properties between model and viewmodel and vice versa. I could use automapper to do this but since I don't need mapping rules to convince me to use it as I ...
4
votes
3answers
670 views

Determine payment based in the number of adults, number of children, and some combo box selection

How can I shorten this code with a while loop? Is it possible? cboFrom and cboTo is a combobox. I only know how to do simple ...
2
votes
1answer
36 views

Simplify my class mapping common class properties between model and viewmodel classes

I have an ASP.NET MVC 5 app and I map properties between model and viewmodel and vice versa. I could use automapper to do this but since I don't need mapping rules to convince me to use it as I ...
8
votes
2answers
97 views

SSE instruction to check if byte array is zeroes C#

My fundamental problem is how to check whether byte[] is full of zeroes. I posted a range of implementations (with timings) and one clearly beats others. In fact, ...
-1
votes
2answers
104 views

Use NLog from different classes in a DLL

I started using NLog. I wrapped NLog inside an internal class, for my own needs. Is my implementation and usage correct? If ...
1
vote
0answers
25 views

Securing User Credentials in Cookies

I have an asp.net/MVC5 app that for reasons that are outside of my control needs to hang onto (some) user credentials (username and password) to facilitate certain operations they may perform. I don't ...
2
votes
1answer
33 views

Remove and move elements in a WebBrowser Control page

I'm making some changes to a page on a WebBrowser Control. There is some indications in the code. I just want to make sure that I don't have any unnecessary lines of code. ...
2
votes
1answer
73 views

Controller class pattern

The GetDropdownList() function is being called on a couple of controllers based on this example and it may be called in many other controllers, so this code is ...
4
votes
3answers
423 views

Implementation of a sparse Markov Chain

I need to create a sparse Markov chain. It is supposed to receive text, so the number of rows or columns can easily go up to 20000. Besides, if I want to consider higher orders of the Markov chain ...
3
votes
3answers
48 views

JobTypeLogic and JobType classes in MVC business logic

I am working on an MVC solution. My DAL layer I could solve with Repository classes, everything is working great. But in my BLL layer I have repetitive code: My CRUD is the same, my fields and ...
3
votes
2answers
61 views

Checking if text is NOT displayed

I'm currently writing unit tests in Selenium (C#). I need to do two things in this particular test: Check if 2 errors (with html container) are displayed and check if another (given) error is not ...
0
votes
1answer
68 views

Data Structures C# Dictionary<int,user> and user has a property that is a list<numbers>

1st time posting here. I am about to post a question to StackOverflow about how to do a better job adding a Number to the list inside the User class. But I feel if I refactored this I might solve my ...
-1
votes
0answers
20 views

Checking regex pattern efficiency [on hold]

I have some strings like: @HELLO) AND @X @Y1) AND @TEST I am using this Regex: @[?\w?]\) AND @[?\w?] that detects ...
2
votes
0answers
37 views

Unit of work with Repository pattern

I am trying to work on a WPF application and decided to go for Unit of Work and Repository pattern, along with MVVM. I am using Entity Framework as my ORM. Could ...
2
votes
4answers
255 views

Implementing a thread safe log class with simple functionality

I have finally assembled an attempt to create a thread safe logging class and also ensured by file flags that file should not be accessed by different processes at same time. This classed will be ...
2
votes
1answer
89 views

Linq query performance that use ToList()

This code written by @Rahul Singh in this post: ...
0
votes
0answers
35 views

Unit of Work by using Windsor Castle

I want to implement Unit of Work patter with the usage of Windsor Castle in order to controll the trasanctions and sessions. What I did till now is: My business class methods: ...
5
votes
2answers
939 views

Locking mechanism in C#

I would like you to review the locking mechanism I implement in C# class. Will it be working correctly with many threads? Please don't mind rest of the code because I just try to repair the class ...
-3
votes
0answers
28 views

using an array to store integers and print them C# [on hold]

I'm new to C# and trying to learn as much as I can. I have come up with this code to take ten numbers from the user, store them and then print them out using an array. Once I get this figured out I ...
7
votes
0answers
91 views

C# Treap implementation

I recently developed a simple treap data structure in C#. In the future, I may have the class extend IDictionary. For now, I only expose a public accessor and a ...
1
vote
0answers
22 views

Viability of BLL/domain design, using nested classes and IoC

Just looking for feedback and opportunities to further simplify this BLL/domain-layer design. The target implementation would be as the middle tier between EntityFramework 6 and MVC 5. What I'd most ...
2
votes
3answers
67 views

Creating table from code behind

I have to create a table that will allow users to upload different documents for each of the entry in the table. To be more exact, each row will contain a unique ID on first column, followed by 3 ...
1
vote
2answers
33 views

Securing a web service without relying on native authentication schemes

Due to various business and technical circumstances, I have to create an internet-facing .NET 4.5 WCF web service which should be called only by a certain party while not using native authentication ...
2
votes
1answer
48 views

Proxy and reflection Code - looking for exception handling no try/catch

I am currently working on a Redis project and I would love to know where I am likely to run into Unhandled Exceptions in the following code. A General Review would be great, don't hold back. This is ...
-1
votes
0answers
54 views

Good practice for exception handling with additional data

Is it a good practice for exception handling with additional data? I am adding a Newtonsoft.Json object to Data attribute in catched Exception. ...
7
votes
2answers
81 views

IdentifierReferenceResolver: resolving at project level

One of the most important parts at the core of rubberduck is the IdentifierReferenceResolver class, which is responsible for resolving each declaration as the parse ...
2
votes
2answers
49 views

Should I be using a stored procedure for this function in my code behind?

We typically do our saves and deletes for our asp.net pages (SQL Server as back-end) in the code behind. I've seen some reference the idea of creating a stored procedure for this purpose. Is this the ...
0
votes
0answers
16 views

Using custom negotiator and custom formatter in web API 2

Here's my custom formatter which I want to use for "application/x.product" content type: ...
6
votes
2answers
246 views

Audit table queries for various combinations of search criteria

I've created a search page on a rather large Audit table (populated by triggers on every database). There are 4 fields you can search by (and I put each textbox next to each other): User ID, Table ID, ...
4
votes
3answers
120 views

Using an IEnumerator without a foreach loop in order to simulate a state machine

I am working with an object that needs to run an ExecuteEffect() method. Sometimes, the ExecuteEffect() only needs to run once, ...
1
vote
1answer
55 views

Deserializing multiple elements from XElement [on hold]

I'm serializing multiple elements using this code: ...
2
votes
3answers
204 views

DataGrid Filter Method Very Slow

I'm having a lot of trouble in my Database program with trying to implement an effective DataGrid filtering method. After taking advice from a previous code review I'm trying to implement a DataModel ...
2
votes
1answer
99 views

Is this correct implementation of visitor pattern?

I tried implementing visitor patter and have questions about my usage of is and as keywords. Is there a big performance hit when ...
1
vote
0answers
27 views

Business logic in controller

Led by the recently read premise "Lean controllers and fat models" I've come to the conclusion that my controller might be too fat at the moment. Basically, what I'm trying to achieve is simple Edit ...
0
votes
0answers
39 views

Shortest path in BFS algorithm [closed]

I tried to get the shortest path in my BFS algorithm, but I don't know if it's correct. ...
3
votes
3answers
298 views

ATM Console Program

I decided to write an ATM program in my favourite programming language, C#. Tested with a few numbers and I am confident it will give correct output for any valid input: ...
3
votes
1answer
51 views

Dynamic visual list of images

Situation So I have made a list of PictureBoxes on my form that looks as follows: All images have a panel behind them that is 4px lager (2xp all around the picture box). The images are named ...
3
votes
0answers
51 views

Custom Event System in C#

I'm currently writing a game and want to encode everything that happens (GameObject has moved, hp changed, was created/destroyed, got/lost a component, ...) in Events that look like this: ...
6
votes
2answers
87 views

Converting a SecureString to a byte array

Does it allocates something that hasn't freed? Something that remains in memory? Except result byte array, ofc. ...
3
votes
1answer
66 views

Using LINQ to perform a LEFT OUTER JOIN in 2 DataTables (Multiples criteria)

I know that exists a lot of solutions about how to create an OUTER JOIN between two DataTables. I created the following code in ...
0
votes
1answer
27 views

Store TotalCount in ViewState

Is there a more concise way of doing this? ...
2
votes
0answers
24 views

Extracting SoftDelete from DbContext

I have a DbContext with a SoftDelete implementation inside it. To make it more clear and maintainable, I wanted to extract it to ...
4
votes
1answer
239 views

Combining these Add and Remove methods into 1

I was wondering if it's possible to move these add remove methods into a single method: ...