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

2
votes
2answers
29 views

Census data from file input (text)

The program takes census data from a text file in the format age, gender, marital status, district. It then gives a list of residents by district (there are 22) and by 5 age groups. Any suggestions ...
2
votes
1answer
32 views

Shared access point

In my game, people connect to my server. The server creates a GamePeer per connection. GamePeer creates one ...
3
votes
0answers
34 views

Passing a password to a viewmodel

I've got a project I've been working on that connect to a file server and writes some data to a text file. In order to do this I added a textbox for the user to type their username and a passwordbox ...
5
votes
3answers
141 views

Login and registration functions

I'm currently learning C# as first programming language and I've made a simple program to exercise the basic concepts. It's nothing fancy especially compared to advanced stuff you normally talk about, ...
2
votes
0answers
28 views

Removing checks that are only necessary on first pass

I've got a function that's executed in a game loop. There are a couple of checks that are really only necessary during the first pass of the game loop. How can I remove these? There is more code like ...
0
votes
0answers
10 views

Replacing text using DrawString [on hold]

I have a sliding puzzle table and after finding the solution I want to animate it and move the empty tile around until I reach the solution. I have no problem with the generation of the solution, but ...
5
votes
1answer
153 views

Counting occurrences of substring in string

I need to know how many times a substring occurs in a given string. I figured that I might as well create an extension method: ...
3
votes
1answer
31 views

Unit testing HTTP requests

I would like to unit test my web requests, so on top of my head I came up with the solution below. Since it seems to be working fine, I'm posting it on this site. Though it doesn't feel very dynamic, ...
3
votes
3answers
35 views

A basic rocket controller for a Unity game

I'm currently learning C# so I can make real games with Unity. This is the first C# program I've built in Unity. Essentially what is does is control the thrust, and rotation of a ...
1
vote
1answer
51 views

Longest palindrome in a given string using LINQ

Problem:I need to write an algorithm that will return length of longest possible palindrome from a given string. So if the input is aabbbccdfg Program output should be 7. //-->[cabbbac] Can someone ...
4
votes
1answer
33 views

Implementation of the FNV-1a hash algorithm for 128-, 256-, 512- and 1024-bit

A little over a year ago, I asked this question. Since then, I've implemented the larger bit variations and am looking for any and all feedback - performance is obviously key when talking about ...
-3
votes
0answers
17 views

Please help me with the optimization [on hold]

Resources in my program are not exempt and with prolonged use application, it can take up to ~ 500 MB of RAM, which is not I do? How to fix it? If Could you see the source code and share advice. ...
8
votes
1answer
51 views

Rubberduck's “Rename” refactoring implementation

Knowing who's using what, and where, I've implemented a "Rename" refactoring for Rubberduck. It works great - it needs further extensive testing, but the preliminary tests are very, very exciting. ...
-1
votes
0answers
20 views

.NET - LINQ: Using abbreviations [on hold]

When using LINQ. What is your approach to abbreviations? Is it OK to use abbreviations when you write LINQ? Alot of Microsoft's samples uses abbreviations but my personal experience tells me that ...
4
votes
2answers
71 views

Guessing a file type based on its content

In a project I'm working on, I need a component that is able to make a best guess about file's type based on its contents (a Stream). It doesn't need to do a ...
2
votes
2answers
114 views

Extracting a Decimal from a string

I have the following method which extracts a decimal value from a string. ...
5
votes
2answers
252 views

Deeply nested search through Document tree

I have this code block, where I search for the value of Ordnungsbegriff. I have to search through a tree of my CurrentDocument. How can I rewrite it to be more ...
2
votes
1answer
47 views

Web API controller to get details of a travel plan or a leave request

My web API has 3 controllers for get, post and users CRUD. I named it as DetailsControllor, FormControllor and ...
5
votes
1answer
89 views

Multiple functions to establish a fallback value for a property until not null

I have a property (called "Head") that can be set externally. When "Head" is not set, it uses Unity3D's MonoBehaviour functions to try to find the best value for ...
1
vote
0answers
28 views

Checking subscriber download limit

I have a domain model which determines whether a user has any access left. This class is loaded from the database on each web request. The setter on the property that determines the access limit ...
-1
votes
0answers
30 views

DRY the Dictionary and KeyValuePair [closed]

I have this list, private static Dictionary<string, List<KeyValuePair<string, string>>> _myVar; and I am initializing it using, ...
3
votes
0answers
46 views

Using Roslyn to find interfaces within a solution

The intent of the below code is to find all interfaces within a solution whose fully-qualified names match the given predicate. It seems to work, but as I am new to Roslyn I'm guessing there are ...
1
vote
2answers
59 views

MVVM Model modifying data

I’m trying to rewrite one of my projects using the MVVM pattern. I have a feeling though I’ve not done it correctly because I think my Model is too “smart”, it has methods to modify its own ...
8
votes
1answer
55 views

C# AES + RSA Encryption Implementation

I've put together an AES encryption implementation to solve a set of requirements. I believe that I've met the requirements, but I'd like to see if anyone is willing to review the implementation to ...
1
vote
0answers
31 views

Using ASP.NET identity in a new app

I need code review for using ASP.NET Identity in a new app. Goals: Use int instead of GUID for IDs. Separate identity from view layer I need code review if I ...
15
votes
3answers
806 views

Who's using what where - turning code into symbols

The Rubberduck project is coming along pretty nicely, and for the next version the parsing strategy is getting yet another revision, and this time around it really feels like it's done right. Or is ...
0
votes
0answers
22 views
0
votes
0answers
26 views

Is this pattern for passing a LinqToEntities connection safe? [closed]

I've written a Data Access Layer for an MVC app I'm working on. Several Controller methods call several functions from the Data Access Layer. If more than one function is called, I initiate the ...
3
votes
1answer
44 views

.Net BouncyCastle - CSR and Private Key Generation

The purpose of this code is to generate the CSR and the Private Key. The scenario is that we have some clients for whom we run websites and for the SSL component we want to have a page on our site ...
2
votes
1answer
79 views

Adding data to the DB in EF without using navigation properties

Questions: Is there a better way other than assigning IDs manually and creating separate lists for each model the way I have? (for this particular scenario). If so, how? (Still taking the conditions ...
-1
votes
0answers
15 views

Silverlight windows phone 8.1 project: Unable to navigate to page 2 [closed]

I have a weird issue. I am not sure what I am doing wrong. I am doing a Windows Phone 8.1 Silverlight app project that (for now) has two pages. Page1.xaml has a Welcome page with a button, that, when ...
2
votes
1answer
44 views

Restore SQLite database backup

I have an application that provides the user the ability to backup the local SQLite database to another location. I then provide the ability to restore the backup database and overwrite the current ...
5
votes
1answer
62 views

Grouping queries

I have a list of Options. From that list: First I want to get only Drink (the where clause). Then I want to group them by their SortOrder (range of 100). I can ...
2
votes
2answers
46 views

Converting a DropDownList retrieval service to generics or delegate methods

mappingService below is actually just Automapper. I have a wrapper around it so that I can inject it. I want to refactor the following code to be cleaner: ...
8
votes
2answers
95 views

Trees and their uses

I was getting sicker and sicker of using an ordinary collection to do a tree's work, so I built a tree. A requirement of the tree are that it needs to contain a key to sort the tree by, so I used a ...
4
votes
1answer
38 views

Assigning values to a particular table column

I have a set of Excel data which I read and assign to corresponding columns of an Excel table. In our Excel we have provided the user the option to rearrange the Excel column fields at runtime. ...
3
votes
2answers
68 views

2D vertex of multiple countries

CodeChef - QPOINT Given a 2D vertex of multiple countries, find which country contains a certain point. Input format: ...
2
votes
0answers
36 views

MS VS solution structure w.r.t. dependency injection unit tests?

Is the following MS VS solution structure and classes OK w.r.t. easy unit tests with dependency injection? Would your unit tests look similar? If you call the calculations below over a WPF module, ...
6
votes
2answers
76 views

Simple binary heap in C#

I've written a simple binary heap in C# and I want to know if it has any problems or if I can make it better. ...
2
votes
1answer
44 views

Cancellable progress form using async/await

Introduction: For a project I'm working on I used a BackGroundWorker to lift some heavy tasks away from the UI thread and report progress. For this I created some ...
3
votes
2answers
65 views

Unity simple map generation

I am trying to generate a simple map like this. Everything works as I want, but I am new to programing. Is it a good way to do something like this? And if not, could someone explain to me where and ...
13
votes
6answers
712 views

My Rational struct, version 2

I implemented most of the suggestions from Version 1. Thanks to all who took time to review and offer really good comments. ...
5
votes
2answers
1k views

ViewModel creator design

I am trying to move some logic outside my controller for creating my view models for the view. I have a lot of queries to fire to make sure the complete view model is ready, so to keep my ...
8
votes
4answers
251 views

My Rational struct, version 1

I have written a Rational struct for working with rational numbers, i.e. Rational(int numerator, int denominator). A recent ...
1
vote
3answers
47 views

Creating default parameters for a TestResultDefinition

I have a method which creates some default values in an ObservableCollection, nothing too fancy, but I'm trying to decide how to write the if statement. ...
0
votes
0answers
54 views

Is this an acceptable way of calling common async code from a derived method?

I'm implementing a number of classes in C# that have async methods. However, each of these methods needs to implement some boilerplate code that is common to all. Therefore I've implemented the common ...
2
votes
3answers
139 views

Compare collections

I have two Collections and want to compare them. ...
3
votes
0answers
47 views

Async SerialPort Wrapper

I've been working with the SerialPort class for a while, trying to figure out the best way to work with it, and especially adding support for Async-Await in C#. I ...
0
votes
1answer
58 views

Efficient use of LINQ - Indexing

I have a Class with a List of objects, and those objects contain a list which has lists to objects in the first class, and I'm trying to quickly index them. Simplified: ...
6
votes
1answer
95 views

Abstracted Interface for Settings

I just learned about the beauties and wonders of interfaces. And, I realized how I could fix some code that has been bothering me because of its duplication. This ...