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

1
vote
0answers
25 views

SQL Injection - Validating user supplied input

I was assigned a task to fix the SQL injection flaw reported by a code analysis tool and I am not the original author of the code and I do have fair amount of knowledge on SQL. Here is the code... ...
0
votes
0answers
14 views

Restricting mutliple async tasks from being executed in C# [on hold]

I have to restrict multiple async calls from being executed. I want to show a message when second task is trying to execute before the completion of a previous task. Please find my approach here. ...
7
votes
2answers
281 views

Checking if a point is on screen

I'm working on a tile-based game, and am looking to improve the efficiency of my code to slightly improve framerate. I call this method on every tile, every frame, so it is very performance critical. ...
2
votes
0answers
18 views

WebAPI Client Proxy

I'm working on a client proxy for my WebAPI. I've looked at WebApiProxy but I feel DTOs are unnecessary in my scenario. I made an ...
3
votes
0answers
18 views

Local report RDLC to PDF

Is there any way to improve the performance of local report or even an alternative if not? I have been looking for a solution for quite some time but the general consensus seems to be that it's just ...
1
vote
1answer
72 views

Web application for consuming a REST service

The application is a web application that consumes a REST service. Web config has the REST URL along with the parameters. REST URL and the values are passed as ...
3
votes
0answers
46 views

Generate N pairs of checkboxes and N textboxes

I've written a piece of code, where a pair of checkboxes and a textbox are generated N amount of times. Depending on what's in the DB, the checkbox/textbox may have a default value or are left empty. ...
4
votes
3answers
266 views

Handling arrow keys for a console menu

I have a relatively long method, and I'm wondering: How readable is it? Is a method this long okay, or will it be bad later on? Note: This method enables users to select from a console menu - ...
2
votes
1answer
23 views

WPF Data binding alternate datacontext inside Itemscontrol

What I'm trying to do is bind the controls generated by a ItemsControl.ItemTemplate to a new instance of my ContactInterface ...
0
votes
0answers
43 views

Using delegate and inheritance to determine which method is run by the child class [on hold]

I have a child and a parent class in C#. I want to point the Calc delegate to one of several methods. this is determined each time the Reset() method is called. ...
5
votes
2answers
44 views

Method that renders all existing drawn lines on the view

I have several tabbed views with a Unity scene in them. What I do between scene is hide the elements in that scene, then render them if the right view is shown. The method below is the method that ...
0
votes
1answer
62 views

C# Interfaces - Making them more generic, Adding specific\bespoke methods [on hold]

I'm writing a generic import\export program to import\export Stock and Sales Orders from a number of legacy accounts systems. I'm loading the correct concrete classes using a factory pattern, so the ...
8
votes
4answers
375 views

BFS search function

By profiling my application, I found that the bottleneck of my application is the function below. In particular it will be executed by a lot of entities (monsters) in a game, that will go onto a ...
3
votes
2answers
102 views

Permutations in C#

I have a program that will get all possible permutations of a certain equation: A + 13 * B / C + D + 12 * E - F - 11 + G * H / I - 10 == 66 Where A, B....I is a value 1-9, and where each digit ...
-4
votes
0answers
39 views

Nullable bool different than true [on hold]

Which one is more human readable, less complex and easier to maintain? Is there more readable way to write something like this? Expression should test if request.IsInvalid property equals ...
4
votes
2answers
87 views

Async & ContinueWith

I am implementing my own UnitOfWork for an EntityFramework-DataContext. I want to call ...
7
votes
2answers
65 views

GoTo Implementation: First-class navigation for the VBE

ReSharper has a very handy feature that's particularly useful when coding against abstractions. Since coding against abstractions is something that can also be done in VBA, the next release of ...
8
votes
3answers
361 views

Constructing a query string using StringBuilder

I speedily wrote a bunch of crappy checks, to check whether strings are empty, in order to build a query string. ...
-2
votes
0answers
15 views

Parse.com Fast retrieval windows phone 8? [on hold]

Is this the quickest way to return an object from parse.com? I want it to return a list which I can then use to databind against listviews in windows phones. I would like something that's more ...
1
vote
1answer
48 views

Method that checks whether to disable or enable the buttons depending on whether data is null or not

I have this bit of code that needs refactoring/simplification. The below grabs the planning data for view A and B. Then it joins the planning and matching image for view details. So then it determines ...
3
votes
1answer
71 views

Extracting opening and closing times for each day of the week

I have these two methods: ...
0
votes
1answer
36 views

A non-static Sieve of Eratosthenes class, version 1

Over the years I’ve seen many C# sieves and despite their varying internals all that I have seen invariably are a static method that returns a List<int>, ...
1
vote
1answer
42 views

Finite state machine for CSV data

I want to read a file containing comma-separated values, so have written a finite state machine: ...
4
votes
0answers
58 views

“CommandBus” with Handlers & Observers

I'm looking for a very simple (at first sight) CommandBus, which will handle some ICommand publication. The ...
1
vote
1answer
37 views

Track the highest high in a time series

I want to find the highest number in a time series, in the most efficient way. To avoid iterating through all the look back periods, I'm only iterating in case the current high number has just been ...
6
votes
4answers
314 views

C# PasswordService class

I am new to C# and develop a configurable PasswordService class. As the code works the next step is to improve the code. Right now there are the following options: ...
3
votes
0answers
31 views

Number Wizard with an independent logic environment

I was inspired by Number Wizard game question and I decided to write my own version of the game. My goals were to follow the SOLID principles and make the logic environment independent. I'm a bit ...
2
votes
2answers
62 views

Store open days and times

Currently I'm developing my business entities. I feel that the structure is a tad cumbersome. What I mean is that a store on a particular day can have different open and closing times. So it's not ...
3
votes
1answer
44 views

Linq-to-SQL DAL on a Windows Forms project

I just started out a new job as a C# programmer on .NET 3.5. My manager gives me total independence on how I build my modules, which is generally a good thing, but there are minuses too. Having too ...
0
votes
0answers
32 views

Azure Active Directory controller

I have a class called AzureActiveDirectoryController. This class has some methods: one to create users, one to get the app name, one to register schema extensions ...
1
vote
0answers
34 views

A Note class which plays a note and stops it after specific period of time

Update: The original post is below. It seems that I misunderstood the difference between Dispose() and garbage collection. So, the reference of midi_output will ...
11
votes
1answer
93 views

Rubberduck “GoTo Anything” Navigation

The next version of rubberduck is going to include a pretty nifty "goto anything" / find symbol navigation tool that lets the user enter an identifier name in a combobox: UI To achieve the ...
4
votes
1answer
206 views

Pagination implementation for a blog system

Last night I was working on a project that I've embarked upon as a learning exercise. I decided to add a pagination feature to my blog system. I made an attempt at it and got close... but I decided to ...
0
votes
0answers
32 views

Should I use EntityFramework class models or create my own? [closed]

So I am developing an MVC app with EntityFramework and I have this call that retrieves a list of Book which are directly items from my database. I am wondering if ...
0
votes
0answers
5 views

C# What is the best approach to make Data Receive / Data Listener keeps alive? [migrated]

I have task to create a client application for data communication via TCP and I have no experience in TCP data communication programming. I use C# and VS2013. In the company I work at there is a ...
2
votes
0answers
40 views

Refreshing customer list periodically in the background

I have a method RefreshCustomersInternal that refreshes customer data from a server and returns a Task. Since this process is ...
5
votes
2answers
98 views

Calling a method to draw parallel lines

This question is a followup to the last one. I followed RobH's advice and his edge case bug found in my code with this solution: ...
1
vote
0answers
31 views

Generic Sql Connector classes

The need came up the other day to be able to easily switch back and forth between making IBM DB2 queries and MS SQL queries. I didn't want to mess with NHibernate as I was on a time crunch, and I also ...
3
votes
1answer
39 views

Is it an anti-pattern to let ViewModel fill itself from a domain object?

Let's say you have a Employees table mapped to a Employee class. Now you want to code a Edit page for general information. You need a ViewModel with all the properties you need to build the page, so ...
-4
votes
0answers
25 views

Correct usage of async/await [closed]

I'm having some confusing with async/await keywords. I've gone through a couple of tutorials and they seem to follow the same pattern, which goes something like: Create this class and call it's Async ...
-2
votes
0answers
20 views

Occurs when load data in datagridview [closed]

Here my DAO: Dataprovider for excutenonquery with store procedure. ...
0
votes
2answers
59 views

Unique combinations of sets with N min selections of overall set

I'm in the process of attempting to write a parser compiler. In this, sets play a major role. I'm in the 'lexical ambiguity' isolation phase, and to that, I need to yield a set of every possible ...
3
votes
4answers
82 views

Setting new lines and adding them to a list to be drawn

I have a method that basically passes in a known drawn line segment in my view and then draws parallel lines n distances away from the passed in original line. This one in particular draws two ...
0
votes
1answer
19 views

Gridview cookies

On my web forms page, I have this huge GridView. I make it refresh every five minutes since the data has to be up to date. It has sort options, so upon every refresh, I use cookies through every ...
17
votes
6answers
1k views

Sales Tax Problem, rejected for not being up to their standards

I applied for a Junior .NET Developer Position recently, and I was asked to solve a problem (Sales Tax Program) and I was rejected for some reason. The question goes like this: Basic sales tax is ...
0
votes
0answers
34 views

Refactoring data processing method into classes [closed]

I'm building an application that processes email messages in a mailbox, and, for each message, transforms the attachments and then replies to the sender. This application implements an existing ...
3
votes
1answer
43 views

Returning a description based on a minimum and a maximum value

I need to return a "human readable" description based on a minimum and a maximum value. Note that the minimum is included in the condition, but the maximum is excluded -- so for instance if the ...
0
votes
0answers
28 views

Error management for order transactions with rollback support

I have a domain with this kind of code: ...
9
votes
2answers
102 views

Reordering method parameters

Next release of Rubberduck (should be 1.4) introduces a reorder parameters refactoring, which lets user reorder the parameters of a module (or class) member, and automatically adjust all usages. ...
2
votes
2answers
78 views

Reading data from database, saving to new list and adding list to grid

I made some changes to how I was saving the data in order for it to show up on a kendo grid. Right now my giant method is getting data from the database (using ...