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
7 views

Displaying picture collections from a user's picture library

Currently, I have been digging up my old codes. One of the applications I worked on was an Image editing phone app that displays a collection of random pictures from a user's picture, which I limited ...
3
votes
1answer
44 views

Passing variable to BackgroundWorker and use the same value later

I create multiple BackgroundWorker within a for-loop and each of them needs to know a special value. To simplify, it is just <...
2
votes
1answer
15 views

Verify if user has at least one of required roles to be able to update a record owned by a certain user

I have a Microsoft CRM 2016 plugin that checks if the user that triggers an update message has at least one of the required roles, when the updated record is owned by a specific user. Here's the code:...
4
votes
0answers
16 views

ListBox with a dynamic number of TextBox elements

I am making a kind of form, and I want the user to be able to enter a dynamic number of string inputs. The idea is that a single TextBox will be displayed, and once ...
6
votes
1answer
52 views

Get host ip address behind load balancer or without lb

Description Aplication type: WEB API .NET Framework: 4.5 MVC: 5 I need caller host ip in my custom action filter and then in action. On some enviroments we have configured load balancer which ...
0
votes
0answers
13 views

ASP.net MVC Controller that relies on a WCF Service - Error handling

Inside one of the Controllers of my MVC application, I have the following. ...
0
votes
2answers
42 views

Randomly re-partition 1Dimensional List to 2Dimensional [on hold]

I wrote a solution Please look at the my approach is correct? There is a better solution? ...
9
votes
2answers
126 views

Structure to ByteArray Extension

I have a need to turn various structures into byte arrays to be sent over serial port to another machine. I created generic extensions to turn any structure into a byte array and from a byte array ...
5
votes
2answers
55 views

Task Parallel Library and Mailkit

I have a use case where I need to process about 80,000 emails per day. The client has an existing process that takes about 1/sec per email and is running out of time before the next batch comes in. ...
6
votes
2answers
201 views

Get directory permissions for all directories in tree

I have made a program that given a directory, will get the permissions for that directory and all sub-directories. The output is stored in a string that can be easily written to .csv. Each permissions ...
4
votes
2answers
76 views

3-Axis Coordinate System for a Chinese Checkers Board

About a year ago, my brother and I came up with this cool idea for how to solve the problem of determining if any given "cell" on a Chinese Checkers board was adjacent to the cell in question. ...
1
vote
3answers
314 views

Combine neighboring parts of an array based on a condition

I have written this code which takes a one dimensional array, for example: {"abc","ade","sss","fgw","asd","lka","o"} and turns it into an array of arrays, ...
9
votes
6answers
1k views

Validation that also returns error messages

My Create, Update & Delete methods should return a success and errors list depending up on the result. I want to avoid the ...
2
votes
3answers
82 views

Wrapping a CSV file for access and testing

I have a simple class that represents and accesses the data from a CSV file (using the CsvHelper library). I've tried restructuring the code to allow for better unit testing, but I'm sure the ...
3
votes
1answer
46 views

A Switch for async function invocations

I have implemented a simple "switch" function - that switches and invokes an alternate function, if the function that is to be invoked fails or timesout. This code will be later employed as part of ...
2
votes
2answers
428 views

Poker hand probability — tally best 5 from all combination of 7

Related to Poker Hand Evaluator. This it not the same. This is take best from all combinations of 7. The other is all combinations of 5. Poker is 52 cards - 4 suits and 13 ranks: Texas holdem Hand ...
2
votes
2answers
35 views

Converting XML to DOT

I would like to show an XML tree as a tree using GraphViz Dot tool. Then I must convert it to a DOT file. It is what I have tried ...
1
vote
1answer
51 views

WPF Mvvm async function ViewModel

I worried about this code in a ViewModel. ViewModel shoud not contain any code exept binding's. But without async update ui should stuck. How to improve it? The main problem that this is need to be ...
2
votes
0answers
36 views

C# Winforms MVP (avoiding circular dependencies)

I asked the following question on stackoverflow and as a result came up with the following code to avoid circular event logic when using winforms. There are two occasions where my model can be ...
2
votes
1answer
22 views

Hotkey detection for UI elements

I have several UI elements that can be opened using hotkeys for example the settings menu's key is Escape. The problem is that I have the Keycode stored in ...
2
votes
1answer
52 views

Avoiding code duplication for reading in similar values for each derived class

I am designing a program that handles many types of grooves TKY, VSingle under GrooveType. Each of this groove is paired with ...
-6
votes
0answers
48 views

Limit number of items in Dictionary [on hold]

I want to let a maximum of 10 people in, and also have arrival time of those that I let in. I have used a ...
-4
votes
0answers
27 views
4
votes
4answers
185 views

Poker Hand Evaluator

Poker is 52 cards - 4 suite and 13 rank: Hand is exaclty 5 cards Order of hands Straight-flush - all same suite and in order Quad four of same rank Boat three of one rank and two of another rank ...
3
votes
0answers
45 views

Task-Based Overlapped IO In .NET

I've been working wrapping the Windows API's Overlapped methods in the more usable Task based approach. There isn't much information out there on doing this, so I've been flying blind apart from a few ...
0
votes
1answer
82 views

Setting a textbox value to zero if null

Is this the correct way to set value of textbox to zero when it's null? Is there any way I can improve the calculation that I am doing? ...
6
votes
3answers
258 views

Checking whether relations are equal to foreign fields using LINQ Any()

Can you find a more understandable way to write the following one-liner? ...
6
votes
1answer
44 views

Constructing entities from API with foreign keys

I'm loading three kinds of entities from an API (in csv format unfortunately). While the first two are fine, the third has foreign keys to both of them. What I'm currently doing is constructing the ...
6
votes
5answers
830 views

A buffer that holds and provides the latest n items

I have developed the following code to hold n latest items it has received, and when asked for provide these n latest items. The interface is: ...
3
votes
3answers
66 views

Add multiple instances of a property to a list [closed]

I'm a novice programmer asking first question here although I've gotten tons of help from previous questions. The following code is abstracted from what I currently have working. ...
0
votes
0answers
25 views

Is it okay to use static classes while creating a wrapper for REST API? [closed]

I am consuming a web service in C# using REST APIs. So, I have created a wrapper classes for each endpoint. It seems like a good idea to implement the wrapper using statics. This makes code look much ...
2
votes
0answers
26 views

Changing visibility of ToolbarItem - Xamarin.Forms

I want to fill collection of ToolbarItems from XAML, but change visibility of some ...
3
votes
1answer
71 views

Entity Framework query optimization

A user can track a show, and mark episodes and seasons of that show as watched. To support this I have the models below: Models ...
7
votes
1answer
117 views

Bit shifting and masking

I was wondering if someone could review this simple bit of code that originally was in C++, but now converted to C# as practice in using bit-shifting and creating a sort of a quasi-array functionality....
-1
votes
0answers
34 views

Get co ordinates from user using typed or cursor [closed]

The code calculate the area of hatches in my autocad drawing and display that output on my drawing using mtext.But i want to print output on the drawing so that user decides where the output wil b ...
2
votes
3answers
126 views

Generic Roulette class

I'm looking for some improvements for my generic Roulette class. More information on how the class works is better described, here: https://en.m.wikipedia.org/wiki/Fitness_proportionate_selection <...
2
votes
1answer
74 views

Dynamic wrappper used to unit test ASP.NET Core MVC Controllers that return anonymous objects

Originally created for this answer on SO, I thought there was still room for improvement on the initial basic idea. Also thought about using an extension method to make using syntax simpler. Here is ...
7
votes
3answers
834 views

Simple C# Interest Calculating Program

Sorry if it's a bit long... I tried to make it modular with methods, not sure if I overcomplicated it ...
8
votes
3answers
878 views

Word-counting script in C#

My goal is to read from standard input, break up the input into words (Unicode letters and apostrophes), case-insensitively, and produce a report to standard output, where each line is a word followed ...
7
votes
2answers
87 views

Get users from groups in active directory, disposing of everything

I am trying to get active directory groups with their users, all while disposing of all IDisposable assets when they reach the end of their usefulness. The groups ...
4
votes
2answers
78 views

Search rectangle on bitmap

I have code that loading bitmap from file. And searching for black rectangle(5*5). Can you help me to review it? ...
0
votes
1answer
101 views

Random number generator in C#

I don't know if it is any good. I've never done this, thus, I noticed it is kinda slow. Can you suggest improvements? I may use it in actual software in the future. ...
6
votes
1answer
146 views

Update bitmap in picturebox with data from a socket

I'm working on a screen sharing project, and I receive a small block of images from a Socket constantly. I need to update them on a certain initial desktop bitmap I ...
3
votes
0answers
24 views

WPF Prism DelegateCommand Setup

I am currently in the process of learning WPF Prism and I have four buttons that I want to all go to the same place but with a different value being passed depending on which button has been pressed. ...
3
votes
2answers
50 views

Make all additional threads return from a method using Interlocked.Increment

I need to ensure a method is executed only by one thread at a time. Contrary to what most of the synchronization primitives do, I don't need other threads to wait, I want them to return from the ...
2
votes
0answers
21 views

Wrapper for ActiveDirectory UserPrincipal and DirectoryEntry

After much frustration and leaked memory from working with UserPrincipals and DirectoryEntrys, I have made a wrapper to get the ...
1
vote
0answers
37 views

How to simplify this C# repetitive code? [closed]

GetTranslation function returns a string. ExistsHelper function returns the bool. ...
5
votes
2answers
75 views

Refactoring Calculations through a series of textboxes

Alright guys, I know this isn't the proper way of problem solving, But I need some guidance here. Since I am just starting in programming, the code is not really readable. The Winforms program (...
4
votes
1answer
55 views

Generating buttons efficiently

I've written a Minesweeper program, but my code for generating the buttons is taking much longer than I'd like. Here is the GUI code: ...
3
votes
2answers
55 views

Creating the start of a Caesar cipher

My code takes an input, uses the input to take a number of letters from the start of the alphabet and put them at the end. I intend to use this to create a Caesar style cipher. Is there a way to do ...