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

Organizing Business and Presentation entities [migrated]

Background I am developing a WPF project using the Microsoft Extensibility Framework. This is the basic structure: User Interface (WPF Project) MEF Interfaces (class library, contains all the ...
0
votes
0answers
16 views

What is the advantage and disadvantage of WCF to WCF calling? [on hold]

Is it fine to use wcf to wcf calling ? I have a WCF service which call a class library for Business Logic and These are in two different project in same solution.I have another project which is also ...
1
vote
1answer
53 views

Returning information about the result of a file processing, without using output parameters [on hold]

As part of a C# class CsvConverter that converts various file types to CSV, I am designing a private class CsvConversionResult. ...
4
votes
2answers
157 views

Refactor a code of selection a validator

I have a datatable and have to validate every field in it. I have refactor this code to this below, but a complexity is 15(!!) Should I make something like dictionary with type as Key and Func as ...
2
votes
1answer
38 views

Reduce logic in Web API controller

I have the following scenario - i have a grid on web page that is populated with data. User can check a check-boxes in grid and data is saved to DB on navigating to next page. If they then navigate ...
5
votes
3answers
55 views

Read table row with multiple options

I developing an algorithm to read a row from a table (specificly, I'm reading from an Excel file). I have three conditions about when to terminate the Read operation: When an empty cell is found ...
3
votes
0answers
26 views

.NET WCF Activator for sync and async calls

I decided to re-write my code responsible for WCF calls, as all of my methods had try-catch-...
1
vote
0answers
10 views

Repository and Unit of Work asp.net/mvc/tutorials

I'm so confused after reading so many blogs I'm still not sure which way to go and I need help with Repository/UOF pattern using EF 6. As I was following the example here asp.net/mvc/tutorials and ...
3
votes
1answer
25 views

Find all collection properties of an object and get their values

I have a chunk of code that get's all of the ICollection properties of the passed in object and then takes all of their values and adds them to another ...
2
votes
1answer
41 views

Light Weight Actors

What are drawbacks/benefits of this simple Actor model in C# (Well; it's more of a Message Loop actually, but please enlighten me)? Using this model one can turn any normal, not async class into an ...
8
votes
1answer
188 views

Changing button colors based on user input

I am using C# to get the user's input of how many buttons to change the color of. The buttons are in rows that have 1-10 button in each. If the user enters 11, then the entire first row will be ...
11
votes
1answer
81 views

How can I better name my tests?

I am relatively new to TDD and am trying to adopt better names for my tests. I wrote the following tests abruptly and have since refactored them to the best of my ability, but despite my best ...
13
votes
4answers
1k views

Reusability vs Simplicity

I have a small game I'm working on with a set of interfaces: IHavePosition: public interface IHavePosition<T> { T Position { get; set; } } ICanMove: ...
11
votes
3answers
615 views

WhenAll for .NET 3.5

I am trying to write a version of Task.WhenAll for .NET 3.5 using the "Task Parallel Library for .NET 3.5". This is what I came up with. Is there a better way of ...
0
votes
1answer
41 views

Basic Console server in C# [on hold]

I'm new To C# and I've started this project from a tutorial. This is a basic Console server that accepts multiple clients. I'm making this as a chat server of sorts, to better understand networking. ...
3
votes
1answer
51 views

Data model for tracking currency in a safe [on hold]

I am attempting to design an application that tracks currency and recent transactions in a safe. I am using entity-framework code-first in a wpf desktop application. The first goal is to be able to ...
3
votes
3answers
104 views

Binary addition with strings

The following method will add two strings of any length as binary numbers assuming the characters 1 and 0. I made this for fun ...
4
votes
2answers
103 views

Good practice for client code to MVC WebApi service

I have written a very simple web service with MVC and WebApi. Now I'm working on the client code which will be a WPF application (and soon Windows 8 Store/Phone app). What I have done works, but I'm ...
1
vote
0answers
20 views

Should I use an abstract repository, or abstract gateway when I have multiple implementations of a single interface? [on hold]

I have a single interface called ITask, which several other interfaces inherit from. One being IGTask and another being ...
2
votes
1answer
86 views

Repository pattern best practices using EF 6

Update: Answer to @Ben:----- Interface: I agreed with you and I'm not sure why did I put that and I usually use Get or GetAll ...
5
votes
2answers
52 views

Helper extension to release Windsor component; not sure if it's over-kill

One of the tenets of Windsor IoC (probably applies to all IoC containers too) is to "release what you explicitly resolve", which admittedly should occur rarely. But we have a fair few ...
2
votes
1answer
65 views

Is there better way to shorten this Lambda expression's result selector?

I'm new in LINQ and Lambda expression. I'm not sure is there a way to shorten the result on this o.z.cust.cust.cust.bintAccountNo. As you can see below, the more ...
7
votes
2answers
89 views

TapeEquilibrium implementation does not satisfy all requirements

The Codility's TapeEquilibrium problem asks: Given an array \$A\$ with length \$N\$, indexed starting from 0, find an equilibrium index \$P\$, such that $$\left| \sum_{i=0}^{P-1} a_i - ...
7
votes
1answer
60 views

Response to an answer: Solution to maxMirror problem

Garrett Openshaw had an okay answer to Improvements on solution to Codingbat maxMirror problem? But there were a couple of issues with the code he gave, so I decided to review it and make it a little ...
4
votes
1answer
59 views

Simple way to prevent duplicate logging of errors

I've been tasked with updating our current error logging system to prevent the logging of similar errors (from a single client program) that were probably caused by the same event. The code here is ...
2
votes
1answer
73 views

TextBox rendered as Label

I have created a custom web server control that will have a bool property 'RenderAsLabel' so that I can convert TextBoxes to Labels, for read-only forms. I was wondering if there is any reason why ...
-2
votes
0answers
27 views

Encryption in Java and Decryption using in C# using AES [closed]

I have got two different systems to integrate where the Encrypted strings would be created on using Java platform. However, the encrypted strings need to be decrypted using C#. I have the Java ...
9
votes
2answers
135 views
+50

Do I need ninject when implementing DAL with generic repository and unit of work?

I am implementing generic repository and unit of work for the first time. I would be glad if someone can correct me if I am doing something wrong here. This is how I communicate with my DAL from ...
4
votes
1answer
79 views

Converting string array to string (and vice-versa) for storing via XML

I'm using XML to store data and I need to store a string array in it. The best way (that I can think of) to store a string array is by converting it to a single string. In order to do that, I'm using ...
6
votes
2answers
123 views

Equality Function Generator

I have a small open source library called Equ that I've been using already on several projects. After a rework of the internals I thought I'd ask here for opinions on improvement possibilities. At ...
4
votes
0answers
47 views

ListBox Update Handling

I have UserGroups for Users to be assigned to in a ListBox in HTML form. Items from listbox can be multi-selected or completely ...
0
votes
0answers
4 views

C# Property or Method to obtain information about a collection? [migrated]

Suppose I have a MyList class which extends ObservableCollection<MyObject> where ...
1
vote
0answers
46 views

Interacting with database in MVC

When using MVC 4 Razor (I am new to web), I get concerned about my understanding of interactions between the database and the client. Much like all apps these days, there is a lot of data that is ...
4
votes
2answers
67 views

Searching through various PDF files

I'm just looking for advice on how I can get my code to operate faster. It's pretty quick right now with searching through 30 3-page PDFs, but I imagine once there gets to be thousands of files to ...
11
votes
2answers
1k views

A fraction of the code

Following up on this post, and including some major changes suggested, here's the revised code. Changes include: No longer keeping an IFormatProvider at instance ...
-1
votes
0answers
43 views

How can I get persons to use my applications? [closed]

The internet introduced me to computer programming. At 15 I started learning HTML. At 16, I started learning C#,Visual Basic & some C++. Computer software makes absolutely no money where I live so ...
9
votes
1answer
138 views

Formattable Fraction

I have written this small little program, to test how my Fraction type behaves when used with and without a custom ...
11
votes
4answers
194 views

I'm not sure if I still love Fibonacci, but my code is getting better. How much better?

Technically, this is a follow up to these two questions, but I have taken a radically different approach. Everybody Loves Fibonacci Does everyone still love Fibonacci I finally allowed myself to ...
6
votes
3answers
84 views

Returning the lowest and highest number based on input

This simple console program prompts the users for a number and returns the lowest and highest numbers from their inputs. It is difficult to add more user inputs, though. How can I make this easier to ...
3
votes
3answers
172 views

Optimize parsing more and more

I have the below C# code for parsing. Do you think this is most optimize or I should use generic method or optimization required in these functions themselves? ...
1
vote
1answer
37 views

improve performance of recursive function in c# method

I'm trying to write a function which will cache objects in memory. The function below works, but performance is unbearable. What would you recommend to improve performance? ...
1
vote
0answers
39 views

FormBuilder code suggestions for POCO

I am constructing a form builder in ASP.NET and I am wanting help with the structure of my POCO classes I have the following so far. I just don't see why I need to add to a list and then process it ...
2
votes
1answer
55 views

Validation invoking queries?

I have a question regarding whether it is viable or deemed correct if a validation object invoked a query. Essentially, I have some code that looks like this: ...
2
votes
2answers
53 views

HttpRequest.Json collection - like HttpRequest.Form

I'm looking for a code correctness and best practices review on the following. I created the following in order to prevent using the same code to convert serialized JSON to something more accessible ...
5
votes
1answer
114 views

Changing the type of an object inside a method?

First off, this is not my code. I'm curious what everyone thinks about changing the type of an object inside of a method then modifying the properties of the cast type. I wanted to use composition to ...
2
votes
0answers
28 views

Resolve (domainless) machine name from DNS alias

So I have a URI with a DNS alias, and I need to I need to dynamically replace the alias with the actual machine. I started out with this: ...
2
votes
2answers
118 views

Suggestions on converting these classes to a single generic class

I have two classes that do that same thing with different types. I was thinking of using generics (but I am open to all options). QueryPermissions and the WebQueryObjects come from an external dll ...
9
votes
4answers
279 views

Threshed and Malachi'd: Sieve of Eratosthenes

I took a little bit from all the answers to my previous question Threshing: Sieve of Eratosthenes. This may be bordering on code-golfing, but I think that I have a pretty good piece of code here. ...
6
votes
1answer
42 views

Convert WKT representations of geometries into GeoJson

I am working on a class library in C# to convert WKT to GeoJson. I am getting shapes in WKT out of MSSQL. A lot of the shapes ...
6
votes
1answer
110 views

Refactoring three property methods

I am trying to refactor these three methods into one: ...