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

-4
votes
0answers
19 views

Abort all running threads from the one (not main) thread C# [on hold]

I have rather strange question, but I needed to be done. So, this is my code: ...
2
votes
0answers
32 views

Task Scheduler for small interval and one number of start

Scenario I want a task scheduler that enables my application to schedule some tasks in small time interval. I want to use it in my socket server application. For example: when user connected to ...
4
votes
3answers
71 views

Facebook helper class

This is my initial Facebook helper class. Is this code efficient or is there a way to improve this code? ...
0
votes
1answer
30 views

IReadOnlyCollection with notifications [on hold]

It is not related to GUI. I have a class with: Private List, which is edited inside the class. Open IReadOnlyCollection ...
5
votes
2answers
61 views

Get item from database by ID and get all items from database

I have 2 methods for getting data from the database (the data I get are both List of tuples with doubles and datetimes in it). I ...
4
votes
0answers
29 views

Asynchronous start/stop state transitions

I have a third-party object with asynchronous start and stop methods. Each start and stop may fail with exception. The object is not re-entrant, i.e. I can only call its start or stop method after the ...
12
votes
2answers
171 views

How Long Will Your Smartphone Distract You From Family Dinner?

I wrote a program to simulate this week's 538 Riddler, reproduced below: You’ve just finished unwrapping your holiday presents. You and your sister got brand-new smartphones, opening them at ...
-5
votes
0answers
32 views

Count of one list items in another list [on hold]

I have 2 lists. One list of objects & one list of int as follows: ...
6
votes
1answer
35 views

Async telnet connection over StreamSocket

My team and I have a very poor understanding of best practices in relation to telnet. We have Task.Delay and Task.Wait in the ...
5
votes
0answers
55 views

The Realtor-duck: Encapsulating Fields with Properties

The latest new refactoring for our friend Rubberduck is Encapsulate Field: This image, for the sake of brevity, shows the result of the refactoring and the UI together. The three properties below ...
5
votes
1answer
67 views

How to refactor this mapping class not to violate SOLID

So I have the below (which is working correctly and all my unit tests are passing) but it's ugly and is violating SOLID, I will have to change the class every time I want to be able to map a different ...
7
votes
2answers
247 views

transform string to decimal

This feels wrong: ...
5
votes
2answers
71 views

Find attribute on class property

Since reading Robert Martin's book "Clean Code" I have been inspired to revisit and refactor some of my code to break it down into succinct methods and small specialised classes. Given the need to ...
4
votes
2answers
211 views

Function to split either a string array or string into a string array

I am programming a language interpreter in c# recently and i have created a set of functions that receive either a string or a string[] and splits it by a received string. For example: with a string ...
5
votes
1answer
43 views

Using LINQ to output SQL data from two tables into XML

I am very new to this. Hope someone could help me suggest how to improve the code. I have two tables where I need to get the SQL data and output it into XML format. I am using LINQ method. Below how ...
7
votes
1answer
42 views

MVC binding list of values to checkboxlist in efficient way

Code Objective I have this code which generates and shows list of selectable items that user can post to controller in order to save into database. Model looks like this: ...
1
vote
2answers
91 views

WPF without MVVM

I know I should use mvvm, but just starting with WPF, here is my code: MainWindow.xaml ...
12
votes
6answers
290 views

“Simple” pathfinding algorithm

I decided to write a pathfinding algorithm in order to expose myself to the world of pathfinding and for me to further understand more advanced algorithms such as A*. I chose C# due to its flexibility ...
8
votes
0answers
44 views

Climbing the Totem Pole - Local Variables Become Parameters

Along with the Introduce Field refactoring, I wrote an Introduce Parameter refactoring. I actually wrote this refactoring first, but due to a bug in the parser/resolver, I was unable to fully test it ...
4
votes
0answers
32 views

Joining tables with EF

Here is my database: Here is my viewModel: ...
5
votes
4answers
78 views

Writing to a newly created file, with support for unit testing

When now increasingly making code unit testable, I notice that code gets bloated, only to get dependencies out. A simple file operation, like saving a file, and, if a file with the name already ...
11
votes
1answer
77 views

To read a book thou should have it bought, to buy a book thou should have it found! (Search Abstraction)

I started a hobby project to find the books that I read (paperbacks) so that I can keep track of them (reading start date, finish date, number of pages, etc..) The first challenge was to find the ...
-4
votes
0answers
39 views

Optimize query linq into one for creating table…(Please free) [closed]

I have these 2 tables, Clients (Clienti) and Vehicles (Veicoli) : This function builds an HTML string to send to the view: ...
8
votes
2answers
129 views

short or simple solution for putting values from label to column in excel

I have a code here that counts the number of fruits from Column B to Column AF (31 days). I used a switch with cases from 1 to 31. I'd like my code to be simpler. ...
6
votes
1answer
102 views

Joining datatables to create a new datatable

I am joining datatables to create a new datatable: ...
-4
votes
0answers
56 views

Is this a safe way to write conversion extension methods in C# [closed]

While lurking around in our software source, I came across this piece of code: ...
12
votes
3answers
566 views

Retrieving a csv header

I have two seperate calls that returns a .csv file. I need to extract a couple of headers from the files depending on which one is called. The headers does not always sit in the same index, and the ...
12
votes
2answers
337 views

Input validation for a user

I have a small Person Domain Model as follows: ...
-1
votes
0answers
32 views

update a data by using Dictionary [closed]

private readonly Dictionary<Credentials, Data> _dataToCredentialMap = new Dictionary<Credentials, Data>(); ...
8
votes
2answers
89 views

Code First approach, feeding the table

I have a database (PostgreSQL) from which I want to migrate some data to a MS SQL Server database. I decided to use a code first approach. The question is related to the proper way of feeding my new ...
4
votes
2answers
59 views

Extracting files and directories from a provided list into separate lists

This code gets a list of all files and directories from a specific location. Thes code below works. ...
5
votes
2answers
62 views

Query Builder pattern with use of FluentApi

Recently, I've come up with an idea of building a custom query builder combine with FluentApi. Expected usage: ...
7
votes
3answers
100 views

Downloading files from a Mozilla file server via FTP

All classes on GitHub repo This is the code for downloading files from a FTP-server running Mozilla Fileserver. FtpItem is the interface for the two classes ...
16
votes
4answers
3k views

You are Promoted, You are Promoted, We All are Promoted!​

My latest refactoring for Rubberduck is called Introduce Field - it promotes a local variable to a private field. The three overridden Refactor() methods are the ...
3
votes
1answer
80 views

Suggestion for a lot of chained Task [closed]

I have a lot of Task continuation that depend on .Result of previous Task -> for example: I ...
5
votes
1answer
106 views

C# - Make the static class thread safe [closed]

I have a simple class that I use to logging errors and other informations from my applications. I wondering what will happen when 2 or more threads of the same application would like to log something ...
3
votes
1answer
48 views

Entity Framework Code First Softball Stats Database Schema

I am creating a website for my buddies and I to track all of our offensive softball stats. I am getting tired of maintaining a huge excel spreadsheet and emailing it out every week, so a website is ...
10
votes
3answers
111 views

Parallelized download of multiple images based on URL

I decided to rewrite a previous program of mine from scratch. The result is a lot better than the previous one but now that it seems like it is working I want to optimize it (hopefully it is not too ...
-4
votes
2answers
88 views

Remove from list value where date less than max date value

How can I improve this code? ...
3
votes
3answers
142 views

Unit of Work Pattern for creating users

CreateUser function assumes the data being delivered via parameters are clean and gets called or initiated from the Business Manager (another class). This function is responsible to do the following ...
3
votes
0answers
41 views

Multithreaded Mandelbrot Generator Ver 3

I thought Ver 2 was fairly solid but ending up modifying all but one method for Ver 3. Performance for Generate is the same, but I was able to simplify the method ...
3
votes
2answers
101 views
3
votes
1answer
29 views

Queuing web service calls

Every call to the web service goes through a custom queuing system. This has a limit that is set to 1. Every call that enters the same time with another call is purged and not handled. Not sure if ...
7
votes
1answer
47 views

Handle concurrent request by waiting the result of an already running operation

I need to handle concurrent request by waiting the result of an already running operation. Requests for data may come in simultaneously with same/different credentials. For each unique set of ...
14
votes
2answers
134 views

Semi-primitive IRC bot serving as learning project

I'd say currently my understanding of C# is within the range of (1Beginner-10Intermediate) a solid 4-5. Thus I am seeking to broaden my understanding of C#; I've started coding an IRC bot to improve. ...
8
votes
3answers
414 views

Multithreaded Mandelbrot Generator Ver 2

Update: Version 3 is here. My first version was an answer I provided to EBrown for his original post titled "Multithreaded Mandelbrot Generator". My answer had many good things in it, but I felt ...
2
votes
2answers
94 views

Writing C#'s analog of setTimeout, setInterval and clearInterval

I got tired of starting timer every time I need to do something simple as running some function 5 seconds after something in my code happens. So I tried to write a function (actually, 3 of them: ...
-1
votes
0answers
37 views

Should I declare properties as Interfaces or as Base classes (when they implement both)? [migrated]

I have a class using a group of properties in similar ways (only two shown in the example, for brevity). The general behavior is defined on a base class, while the specific behavior is defined in ...
-1
votes
0answers
27 views

Show status images according to background worker

I work with WPF and have application which try to take data from server. This logic is inside background worker Do_Work event: ...
3
votes
1answer
35 views

Modifying the response object for creating and downloading a document

I've been looking at some code done in C# ASP .NET WebForms and for some reason I really don't like the below code. What is the best alternative for creating a document and downloading it in Webforms, ...