Tagged Questions
C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
2
votes
1answer
69 views
Merge Sort optimization
I was looking at other people code and I realized that mine is not so neat after all.
In this version, I included a base case for the merge part (when there is only 2 elements to merge, just sort it ...
1
vote
0answers
29 views
Using MVC design pattern to create server [on hold]
I would like to to create a server application that listens to a remote client via TCPlistener and output the message to a form.
What I've done so far is :
1) in the ...
-3
votes
2answers
66 views
2
votes
1answer
72 views
Algorithm generating a unique ID based on client name
Following code is supposed generate a new ID (PID) for a new client based on the client name's first letter and the existing IDs in the range which are stored in a database.
For ex lets say if the ...
1
vote
1answer
70 views
Singleton-like pattern for a project [on hold]
I'm changing the inner implementation of a project. In order to do so, I've created an interface that will be implemented in 2 different ways.
One of this ways is by class ...
2
votes
1answer
43 views
Compare Collection with the information in DB using EF and LINQ
I want to inform the Receivers about new contracts we have this week. After I sent the Emails, the Information about sent contracts are stored in MS SQL Database.
To avoid that someone become the ...
5
votes
1answer
99 views
String modification application
Below is working code of a semi complete program. Its purpose is to take an input string of any type and modify it based on rules defined for each type. So in this example I pass it a string in CSV ...
4
votes
1answer
68 views
EntityFramework-based filtering
I am trying to use the following form to enter new info into a database.
I am trying to use the entity framework.
I have the following classes of Interest:
...
0
votes
0answers
17 views
Implementation of unit of work [on hold]
This is not my code, but I'm thinking to implement it for my project but before that I need clear understanding, As I have seen the code I have this feeling that it's just not good. I want to make ...
1
vote
0answers
47 views
Is the following service layer correctly implemented with multiple repositories?
I'm new to design patterns and specifically the Service Layer implementation. I need some clarification on where to use Service Layer calls.
Below is an example of what I'm dealing with. Basically ...
2
votes
1answer
49 views
Parent/child relationships: adding/updating details to an answer
Answer is the Parent table and AnswerDetail is the child. Below works, but I'm wondering if there is a better way to do this using EF?
My Method Signature is this:
...
-2
votes
0answers
24 views
Merge two c# classes with fairly complex inheritance and data types [on hold]
We have a massive code set, so each of the classes is of the form:
...
0
votes
0answers
29 views
Running method for parent and child records [on hold]
I need to run a method for parent record as well as for its child records if any exist. My code looks like this. How can I make it better?
...
4
votes
1answer
33 views
Implementing HTTP Strict-Transport-Security via MVC action filter
HTTP Strict Transport Security (HSTS) is an opt-in security enhancement that is specified by a web application through the use of a special response header. Once a supported browser receives this ...
4
votes
2answers
108 views
5
votes
2answers
84 views
Keep asking the user [after performing an action] until they wish to stop
I have a form that requires the user to select photos to be included in their portfolio before they can proceed to use the app for the first time.
I don't want to spend the rest of my life ...
4
votes
1answer
181 views
2
votes
0answers
14 views
Caliburn Micro communication between list and edit viewmodels
I'm new at Caliburn Micro and MVVM pattern.
I create 3 views (with its corresponding viewmodels):
AppView
ClientsView
...
0
votes
0answers
3 views
Best practice - SQL Schema to store Timerecords for a Time and Attendance module [migrated]
I'm starting a time and attendance module in C# and SQL.
There will be many time rules depending on every shift.
For example:
...
1
vote
2answers
50 views
MVP Pattern used in a payroll solution
I'm using MVP pattern for a payroll system as my final year project. There are about 16 entity classes (like employee, client, ...
0
votes
0answers
17 views
Working with time, going from JSON text file to C# listview display [on hold]
I'm working on a project where I need to be able to store times. For example, from 20:00 till 20:30 or 08:00 till 12:00 etc. Initially I was doing this in a simple text file and from the ...
13
votes
6answers
603 views
Should I return objects from private methods?
I have a private method that is called from the constructor to instantiate a bunch of objects.
I can do it two ways.
...
1
vote
0answers
23 views
Declaring a large number of 2D arrays to be used as 2D graphic sprites
I'm creating a Space Invaders game, and graphics sprites in it are defined as 2D arrays of colors.
It seems like it's going to be cumbersome declaring these arrays the way I currently am:
...
2
votes
2answers
54 views
Increase performance of string matching function
I've benchmarked my program, and have discovered that the single function taking the most time is the one that does the following.
Takes string that is a delimited list, and splits it into ...
5
votes
1answer
35 views
Having children call parent's public events with data generated from a protected event
I don't know that my title describes the code I want reviewed. Hopefully the code is explanatory.
I have an abstract parent class with two children. The parent listens to some hardware notifications ...
7
votes
1answer
92 views
+50
CodeFixProvider that instantiates collections
Another piece of Roslyn-based code, this time a CodeFixProvider.
I'm looking for feedback on Roslyn-specific code:
Am I using the ...
2
votes
2answers
132 views
Is this method a good candidate for a service layer?
Should the following GetPhysicalFileLocation() method in the Car class have its own Service Layer?
...
6
votes
3answers
519 views
Any performance difficulties related to List<Type>?
I'm using the following structure:
class Map
{
public List<List<Point>> points;
public List<Base> bases;
}
...
1
vote
1answer
51 views
Generic, thread-safe MemoryCache manager for C#
Using this question as a base, and using some of the advice in the answers, I wanted to build out something that would be generic, thread-safe, and easy to use for at least one current and several ...
2
votes
1answer
49 views
Using Poor Man's DI to inject helper class dependencies
I had a rather large method in one public class that I refactored into 2 helper classes. The thing is though, that those 2 helper classes have dependencies. I refactored them into helper classes so I ...
0
votes
0answers
40 views
Camera Tilt, Zoom and Normal Mode [closed]
I am developing a 2D sniper game in Unity. It's a very simple game involving a camera and a plane (backdrop image on it).
I want the camera to change between sniper and in normal mode by double ...
6
votes
3answers
202 views
Time Machine service
Recently I had someone describe a "Time Machine" service to me; that is, a service that could be used to change how a chunk of code perceives time.
Normally through calls to DateTime.Now and other ...
2
votes
1answer
34 views
Optimizing playlist processing
I am trying to process an audio library file which is about 350 KB. My application processes each song on the file gets its meta-data and displays it in a List Box.
The problem is that it takes too ...
3
votes
1answer
64 views
Retirement-saving calculator
I asked a math question and was hoping someone could have a look at the code for me as well. Unfortunately you might have to go look at the original question here.
...
3
votes
1answer
48 views
Matching items in different arrays and performing operations on them
I have a data structure that uses a Dictionary<ID,TimeSeries> to hold time series for different products. TimeSeries is ...
4
votes
2answers
155 views
Getting list of daily team goals
The old code I had before was atrociously slow but after some advice and research I was able to take a 2-5 minutes run time down to about 5-30 seconds. That is acceptable, but still looking to have ...
5
votes
3answers
91 views
Calculating total sales from each member
I am building a new system that is using some tables from an old system.
For each user on this new system, I need to go to the old system and total up their sales. Currently it takes between 2-5 ...
-2
votes
0answers
46 views
-3
votes
3answers
71 views
4
votes
1answer
230 views
Excessive number casting & conversion?
I’m trying to improve my code’s "signal to noise ratio", hence would appreciate any tips on improving this, what appears to be smelly code. Perhaps there could also be potential performance ...
1
vote
1answer
24 views
3
votes
2answers
193 views
Is it better to create a class instance, or create an instance each time a method is called?
I am creating a converter for use in a Windows 8 XAML app (MVVM). As you can see in the code below, the converter is used to convert a bool into one of two strings from a language resource file.
My ...
10
votes
6answers
618 views
Increment up the build number in AssemblyInfo.cs on every build
I just wrote this short little program to increment up the build number for my projects every time I build them.
After compiling this exe, I just call it in the pre-build command line.
I did take ...
3
votes
2answers
71 views
IsoStorageManager
A manager for a speedy async saving objects to isolated storage, using serialization from Newtonsoft.Json. A project to play with is here.
...
1
vote
1answer
59 views
Is this a safe way to parse out HTML tag attributes?
I needed a super simple parser to get HTML attributes and their values. I didn’t want to load a big library or anything so I made this.
I realize I am making assumptions here, mainly:
Attribute ...
4
votes
1answer
71 views
Am I even using the Entity Frameowrk and/or LINQ the way it is supposed to be used?
I feel like just because the below works doesn't mean it is correct, I want to improve it but I can't really figure out how. Besides the fact it is down right ugly I feel the performance could be ...
4
votes
1answer
60 views
Database first entity framework, repository, service, UnitOfWork pattern
I have seperated my project into two projects. One is the web forms project and the other is the Model project with contains a generic repository implementation, a service class for each of my ...
7
votes
2answers
274 views
Follow-Up Post Tictactoe now with AI
A month ago I finished and posted my first version of my Tic-Tac-Toe, I received a lot of good feedback and refactored it to more closely suit the MVP design pattern.
I've done some further ...
3
votes
1answer
41 views
Tarjan's algorithm for Strongly Connected Components without keeping SCC in stack
I've been looking for an implementation of Tarjan's algorithm in C#/C++ for a strongly-connected components in graphs, and couldn't find any implementation without use of additional Stack - most of ...
2
votes
1answer
57 views
Can this architecture of base + derived classes be coded more efficient? [closed]
I've got some architecture in my code similar to this. It is about the Construct method in the base class in the example below. This method contains the logic for constructing a building, which is the ...