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

IoC component registration

How do you list your referenced solution assemblies for IoC registration? I was really tired of typing something strange as new [] { typeof(SomeType).Assembly, … }. ...
0
votes
2answers
52 views

Returning a byte array from a method

public abstract class Element { // Removed for verbosity ... protected abstract byte[] GetBytes(); } I'm attempting to create an engine that can create a ...
3
votes
1answer
24 views

Active Directory Query Application - Take 2

This is an update to my previous post about my Active Directory Query Application. I have made multiple modifications, and I request some feedback. Summary: This program queries an active directory ...
10
votes
5answers
525 views

Reusable implementation of IComparable<T>

I often find myself implementing IComparable{T} in different classes for sorting in a very similar fashion: Values meeting criteria X and Y should be sorted to ...
3
votes
4answers
336 views

PermMissingElem- find the missing element in a given permutation in C#

I just encountered this question in codility but apparently this question has been asked in java already (here, here). Task description A zero-indexed array A consisting of \$N\$ different integers ...
-4
votes
0answers
18 views

What is rx timeout:2500 in xamarin android? [on hold]

Keep getting output of rx timeout:2500 while trying to add a path to google maps in xamarin android. what exactly is rx timeout and how do i avoid it? I can't find it on the internet :(
1
vote
1answer
94 views

Creating archive from over 3GB of files in less than 1 minute

This is a follow up to this question. I got some very good answers for my process speed, and wanted to go ahead and share what I've done with the program. The new updates of the program consist of the ...
5
votes
1answer
60 views

Merging trips to the same location with overlapping dates

I have a SQLite database that only contains the holidays for 1 user. I have a new Trip object (newTrip) that has a ...
1
vote
1answer
61 views

Moving files while preserving the folder structure

I'm writing a console application that will look through a directory and move any log files that have a date modified older than X days (configurable in the ...
2
votes
0answers
37 views

Clean Way of marshaling data

I've been working on a game that I used to play as a kid. This game was disassembled then converted to C# by someone else and they hosted it on Github. I've forked it and started working on it some. ...
4
votes
3answers
562 views

Exclude scores when flag is set

I am not sure if I am just having a brain lapse here or if there is a better way to do this: I am trying to only add one to count in the following scenarios: the ...
5
votes
1answer
65 views

Speeding up process time while archiving files

I asked this question on Stackoverflow, and was told I might have better luck here. I'm new to c# and have created a basic file archiver. It works, and it does what it's suppose to do, but I think ...
-5
votes
4answers
144 views

How can I implement switch without code redundancy?

I have the following switch: ...
2
votes
1answer
71 views

Checking for vowels rewrite

A few days ago I posted a little program that would check for vowels within a given word. I have rewritten this program, it can only find vowels in the English language still but, it will now tell you ...
3
votes
1answer
62 views

User editable properties with varying number of arguments

Recently I used this pattern to create a list of properties, each property having a varying number of arguments. The properties list can be made at compile time, it does not need to change at ...
3
votes
1answer
87 views

Retrieving collections from a database

I have two collections that I want to retrieve from the database and associate with each other. My solution works, however I know it isn't the most elegant one. Do you have any suggestions on how to ...
3
votes
2answers
213 views

Active Directory Query Application

This application is designed to query an active directory, and at the moment, performs only two tasks: Save a list of all users to a file. Save a list of all groups that all users are in to a file. ...
3
votes
4answers
134 views

Property caching

Trying to figure out how to efficiently cache property calculations with dependency tracking to invalidate the cache. Here is the syntax I have at the moment (one ...
-1
votes
0answers
13 views

Linq to Xml - Update existing xml document [on hold]

Hie everyone. Im tring to update an existing xml document that is part and parcel of the application. The xml document contains instructions for the application. I have been searching how to save and ...
10
votes
2answers
158 views

Python 3 decompression routine 10x slower than C# equivalent

I'm relatively new to Python 3, especially IO programming, writing a Blender add-on to import model data. The model data is available in a custom compression, and I originally wrote code in C# to ...
3
votes
1answer
90 views

TryRetry - Try, Catch, then Retry

I have created a class to try, catch and retry N times. My class also supports retrying asynchronously. I'm wondering if there are better ways to implement this. I'm most concerned with the ...
2
votes
1answer
51 views

Protocol to parse packets

I coded this simple protocol but I'm sure that it can be better, this is the process: Reads incoming data Waits until payload size can be read Reads the full message Checks if there are mixed ...
1
vote
0answers
16 views

Binding an ObservableCollection<BitmapImage> to a FlipView Properly

I am currently working on a Universal Windows Platform App. It involves using a flipView to display a certain number of pictures in the user's picture library e.g ...
1
vote
0answers
25 views

.NET List Serializer design

A few weeks back I wrote a class to help serialize/deserialize objects file. The file format requested was json, then compressed. After some coding/testing I settled on this design: ...
6
votes
2answers
223 views

Rock-Paper-Scissors game with OOP concepts

This is code for a Rock-Paper-Scissors game I made using some of the OOP concepts I learned in C#. I don't know if I am making the right choices but I am fairly confident. It would be great if I could ...
0
votes
0answers
21 views

Populates and prints a crystal report using three command line parameters in c#

Let me start by saying that this is the first c# program I have ever written. I'm more of a c/c++ novice programmer, and still relatively new to object oriented programming. This code works and does ...
2
votes
0answers
24 views

Smart copy for windows ce in C#

I have tried to implement a smart copy in C# for windows ce, my version is somehow not performing better that the File.Copy method it's almost the same performance. ...
0
votes
0answers
19 views

Modeling of customers and suppliers as business relations [on hold]

I'm getting started with Object Oriented modeling, so I thought this was a good question for Code Review. Let us consider that we are building a system which will be used by a company that has both ...
2
votes
1answer
25 views

Range class to represent limited values, like HP, Stamina and so on

I made a small script for Unity3D, meant to be use as GameComponent for GameObjects. It is supposed to represent values that have a max value, and an actual value. In games that would be the case, for ...
0
votes
1answer
51 views

Probability Chance

I'm creating a game and I need some properties to work as percent chance to hit/dodge. I implemented a small testing program that takes percent chance and the amount of hitting attempts as input and ...
-2
votes
0answers
16 views

About C# merge sort on linked-list [closed]

Maybe someone can help me out with writing main(); I wanna check if this merge-sort works with linked-list, started out c# just today and having problems with ...
1
vote
1answer
53 views

File archiver, archive files into a zip file

I've created a simple little file archiver that will run through a given directory and extract your files into an archive folder. It's pretty cool if I do so say myself, I would like some critique on ...
5
votes
10answers
404 views

Rotate an array to the right by a given number of steps

Recently, I encountered this coding exercise on codility and the idea is A zero-indexed array A consisting of N integers is given. Rotation of the array means that each element is shifted right by ...
1
vote
1answer
26 views

Slow Filtering Method on DataGrid

Sometime ago I asked a question regarding a slow Filtering method for my DataGrid. Months later and I have a relatively quick method, though I am still looking to ...
3
votes
0answers
95 views

Is Pokemon exception handling ever acceptable? [migrated]

Normally, I don't anticipate exceptions and if I get them, its something that I can't fix in my code - bad user input or connectivity issues with the database. But errors do occur so at the very ...
2
votes
2answers
60 views

C# SerialPort implementation

I'm writing a C# WPF project built with a MVVM pattern. This software is written to use a medical diagnostic device, so in our planning it will be certified IEC 62304. Since I've been mainly writing ...
7
votes
1answer
107 views

Basic C# calculator code

I have not had any experience with coding before, and after beginning to learn I stated working on this calculator which runs different functions on the console. I'd like to hopefully be taught what I ...
3
votes
3answers
387 views

Switch case reviews, finding days of the week that coresponds to a number given

Given a number between 1 and 7, this will display which day of the week corresponds to that number, starting with Monday. This is pretty simple and pretty easy, but it seems that there would be a much ...
7
votes
5answers
1k views

Checking if a string contains vowels

I'm just learning C# and wrote a little program to check if a word contains vowels, it's fairly simple and not to exciting but I would like to know if there's ...
2
votes
1answer
905 views

Login system using a persistent cookie

I want to be sure that my code below properly secures the website based on all of the information provided. Login System Overview When a user logs in, the following user info is saved to a ...
4
votes
1answer
69 views
+50

How to separate data from logic when serializing types - grid tile map example

I am creating a tile based game in Unity and ran into a problem with my architecture of the Map and Tile types. The tile class contains logic like events when the tile type changes. When I tried to ...
3
votes
2answers
48 views

Returning rental invoice data transfer object

When trying to follow single responsibility principle, I often find myself in a position where there is so much to do that I do not know where to start. Maybe there is there a rule of thumb that I ...
1
vote
1answer
51 views

Improving GUI update call from a worker thread in winforms

I have a winforms app and I've been using the following approach to update controls on the main form from worker threads: GamepadManager class has: ...
4
votes
2answers
95 views

Optimise nested loops used to compare champions which have abilities which have effects

I'm creating a counter picker for a game called League of Legends, and for this I need to compare effects of abilities, which each champion has. For this I'm using 4 lists of champions, the ...
1
vote
1answer
49 views

How do you pick the strategy for the strategy pattern in the first place

It is the case where data contains some field indicating what type of strategy should be picked. I mean, I often ignore solving the problem like shown below and duplicate the problems that strategy ...
-1
votes
0answers
16 views

C# - iTextSharp Bookmark Shift Page Numbers Issue [closed]

I am using the iTextSharp to merge several .pdf file into one file with bookmark on left panel. all the stuff is fine except that when click bookmark item cannot point to the corresponding page, ...
2
votes
1answer
28 views

Distributing a purchase quantity into rated bands

I am working on a monthly billing application that utilises a rate band pricing mechanism to reward increasing consumption within a designated billing period. For example: Say I have the following ...
3
votes
0answers
46 views

Optimising looping through large data set and updating database

I have a database table storing information about documents (MigrationMaster). There is another table with security information on these (DocumentSecurity). There are 4 steps I can see that I need to ...
13
votes
12answers
2k views

Project Euler 8: Maximum product of 13 adjacent digits

Problem 8 on Project Euler which asks Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the product? This is my solution in Visual C#. ...
0
votes
0answers
35 views

Dynamic mesh generation in Unity3D

While I can often understand the performance reasons behind using arrays to store vertex, triangle and UV data, I've often found it somewhat annoying because it makes dynamically generating meshes ...