Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.

1
vote
0answers
9 views

Xamarin Forms with Ninject navigation service

I am new to Xamarin Forms and I have been searching online finding ways to set up navigation in a MVVM fashion. In particular I am designing around a concept I found here. However, I am using Ninject ...
-4
votes
1answer
65 views

A better way of splitting encoded data; RegEx vs String Operations?

The obvious answer here is to use RegEx for optimisation but I thought someone might like the challenge during their lunch break. The reasons for why I'm decoding these strings would make for a whole ...
0
votes
0answers
40 views

Parsing strings to decimals [on hold]

Context I have a Selenium test which asserts certain values are the same throughout the program workflow. There are four values altogether and three of them are always displayed with two decimal ...
8
votes
2answers
292 views

Int to Enum Extension Method

As you know, converting an int to an enum is straightforward. Doing it generically with type/range checking isn't. I looked for a reusable example since this seems like a common situation but did not ...
-6
votes
0answers
24 views

Null exception on initializing list in class [on hold]

I have the following class which contains a List. After instantiating class I initialize each member but I receive a Null exception when I try to initialize the List member. p.FACILITY_TYPE is not ...
2
votes
0answers
33 views

Handling authentication in mobile app

I have a mobile app, made with Xamarin.Forms and Prism.Unity.Forms. I would like feedback on whether my way of handling login/...
-4
votes
0answers
42 views

The optimal way to decouple business logic from controller [on hold]

The rule is that controllers shouldn't have business logic, instead they should delegate it to the services. But when we do that, we can't handle all possible cases and return appropriate HTTP ...
0
votes
0answers
34 views

Generating bingo boards with non-repeating sequences [on hold]

I am trying to write a bingo board generator. There are 40 possible entries, each board has 5 x 5 cells, and I need 25 boards. Each board has 12 winning sequences -- 5 rows (...
0
votes
1answer
23 views

AppTaskWorker - Running class methods at sporadic intervals

I decided to write a class to do this for me. I had a lot of methods that needed to be invoked at sporadic intervals, across multiple projects. The dictionary will eventually be class methods, I ...
7
votes
3answers
420 views

Method for returning valid URLs from a sitemap URL

I need a method which fetches all of the text from a URL (generally a sitemap URL), and returns an IEnumerable of all valid URLs contained in the text returned from ...
3
votes
0answers
38 views

Using Threading.Timer to update a list of data

Attached is some code I have written for my application. It is an OWIN based web server which connects an Alexa Custom Skill, my security camera feed, and Microsoft Azure Face API. The number one ...
-1
votes
1answer
58 views

Mechanism to retry failed requests, with throttling

I have a simple event that the client sends to the server, the server can then respond saying if it was successful, or if it failed for some reason. The client has to send a auth code, which is ...
0
votes
1answer
54 views

Asynchronously fetching data from the database

The following C# code is written to fetch the Categories data from SQL Server Database using Asynchronous Task for HttpGet. The Dapper library is used as ORM. I ...
-3
votes
0answers
36 views

Initialising the variables [on hold]

I started to learn C# and while I was writing the same code 100 times in a row, I was wondering if my design is not optimal or I am writing sloppy code. ...
4
votes
1answer
63 views

Multiple client TCP stream reader

My server code is currently reading String data over a TCP connection form 2 different client computers. To do this I am duplicating the ...
6
votes
2answers
92 views

Console autocomplete for complex names

I am currently writing a C# console application. Part of it is, that the user needs to enter a fairly complex system name. To make it easier I wrote a function that uses a string[] keywords and auto ...
3
votes
0answers
39 views

News reading application version 2

following the answer I got from t3chb0t last time News-reading application using the Observer pattern and also following the example here https://msdn.microsoft.com/en-us/library/dd990377(v=vs.110)....
-4
votes
0answers
44 views

Is it thread safe class? [closed]

Do I need locks in my code? Is it thread safe? I want to use for my multiple producers and multiple consumers model. Maybe Is It better to use a not concurrent collection with locks? ...
-3
votes
0answers
43 views

What are the possible ways I can make this EF6 code more performant?

I am using EF6 in one of my projects. Let me first elaborate the requirement. 1. This is being used inside a RESTful web-API app which talks to the Oracle DB using Database First approach. 2. I have ...
7
votes
2answers
168 views

Iterator for BFS binary tree traversal

I implemented an iterator pattern for C# using IEnumerator and IEnumerable. The goal of the implementation is to traverse a ...
6
votes
2answers
293 views

Looping through a string finding nested brackets

So I've been trying to check through a string, looping for, [ (start) and ] (end). In this, I also have to check for nested ...
0
votes
1answer
57 views

Performing actions on the properties of a JSON object [closed]

I wanted to make a class that helps me perform actions on the properties of a JSON object. I wanted to be able to use that class in this way: ...
4
votes
2answers
121 views

EnumerableHelpers: a partial implementation of LINQ for .NET Framework 2.0

Here is a static class with some helper methods for some common LINQ operations on enumerables, built against .NET Framework 2.0. This class is part of the xofz.Core98 library. Edit: a full review ...
-1
votes
1answer
38 views

Making filters based on checkboxes [closed]

I have a scenario where I do filters depending on checkboxes checked. Now I have only 2 checkbox and I need to cover all escenarios into if ...
6
votes
2answers
156 views

Find char which appears maximal number of times

I had 15 minutes to code the following question: Given a file name return the char which appears maximal number of times. please do not take into account the unit test. Please look at the final ...
-4
votes
0answers
72 views

Format data for a CSV item

This function formats the text in each cell of a CSV. The goal of the function is to make sure that the sequence of characters in text will never break the cell's ...
-2
votes
0answers
47 views

Generic function with more than 1 dyanamic types good practices [closed]

I have a repository pattern, if you check below code, here the return type & parameter T is defined which will implemented by calling methods so at run time it will be replaced by SomeClass and ...
1
vote
1answer
35 views

Service locator for a 2D game

I'm currently developing a simple 2D game engine and I was just wondering, what are some things that I can do to improve my service locator class, at the moment it's very basic. For example, should I ...
2
votes
0answers
39 views

Updated Minesweeper library for any GUI

A Minesweeper library that can be included with any GUI. It is an update to Minesweeper library for any GUI. I have done many updates with regards to the answer. Three sections: Game, Board and Tile....
0
votes
0answers
33 views

Identifying objects as some type of enum

Please review my code. It works as it should but I think about making it more pretty or optimal. This method should take in some IEnumerable of ...
-2
votes
2answers
69 views

Generate cryptographically strong random string of characters [closed]

The method below is returning a string of random characters using RNGCryptoServiceProvider. The return string result is built by ...
0
votes
0answers
84 views

Reverse a linked list

I was given 15 minutes to write the code to reverse a singly-linked list. What do you think of the code style here? ...
1
vote
0answers
31 views

Retrieving OS Platform .NET Core

I'm retrieving the operating system platform with .NET Core with system.runtime.interopservicesI have created the code below and was wondering if there was any other way that I could improve it since ...
1
vote
1answer
24 views

Creating an instance of an unit of work (NHibernate)

I'm trying to figure out how to create a NHibernate UnitOfWork using .NET Core Dependency Injection. I was just hard-coding the ...
3
votes
0answers
35 views

Structure and Implementation of Generic Repository and Unit of Work patterns with Dapper and SqlTransactions

I am attempting to update some legacy code that I work with, but my knowledge of data access is limited to a basic use of Entity Framework and simple Dapper. After some research, I have a loose ...
10
votes
4answers
693 views

Calculating primes until a user-given value

I am new to C# programming. I wrote a little program in C# to calculate all primes until a user-given value. Ignoring the lack of computing power I wrote this program to handle theoretically very huge ...
4
votes
1answer
52 views

Accessing View from ViewModel

Having a view (grid control) that provides some functionallity via methods (primary SerializeView / DeserializeView) that should be called from the view model which is bound to the view. One point to ...
5
votes
2answers
681 views

Remove the first value for a doubly linked list

You need to remove the first element which contains a given value from a doubly linked list. I created two solutions since I find the edge case of removing the first element to be problematic. So I ...
1
vote
0answers
21 views

Searching through a TreeView by expanding found results and collapsing others [closed]

I have a WPF TreeView which is populated with many child controls. All of them with children themselves are ...
2
votes
2answers
91 views

Subscribe to Event form one service to another

In my architecture I have service layer, and for my question two relevant classes in this layer: UserManagementService EmailSenderService In first service there is method: ...
1
vote
0answers
18 views

Uploading images to a server

I wait 5 to 6 minutes for the photo to be post to the Azure server. The other data (.txt etc.) is added quickly. That is, there is a delay when adding photos alone. This problem didn't exist before ...
7
votes
1answer
128 views

Minesweeper library for any GUI

A Minesweeper library in C#. To be included with any GUI stack. Did some breakpoint tests and unit testing, seems to work fine. I'm asking if the code makes sense to everyone, and if there can be ...
1
vote
0answers
44 views

asp.net core - get User at Service Layer

I use ASP.NET Core 2.1 and would like to fetch User at a service level. I've seen examples when HttpContextAccessor gets ...
6
votes
3answers
166 views

Custom integer parser optimized for performance

I want an integer parser so fast it risks discovering time travel. I'm stuck in C# for a language, but that doesn't mean I can't try to use c++. So I wrote the following: The best I could do ...
1
vote
1answer
93 views

Async await multiple API calls

I have an application that needs to contact a remote API many times to request information about various products. It was taking around a minute with synchronous programming. I adjusted all my methods ...
3
votes
2answers
113 views

Writing a generic casting extension-method

I'm writing a C# extension-method that converts any object to a type. E.g. the method shall convert a string with value "y" to a ...
10
votes
2answers
820 views

Clearing all controls

I'm clearing all the controls on a windows form with the following ...
4
votes
5answers
160 views

Use filename to determine file type

This is legacy, so I'm not really looking for improvements on architectural approach. Here's what the method does: Extracts filename from a string containing full file path (passed in as parameter) ...
3
votes
1answer
41 views

Generating absolute URIs behind a reverse proxy

In my ASP.NET MVC application there are occasions where I need to generate an absolute URI, such as when sending an email confirmation link to a user. The most straightforward approach is to use ...
3
votes
1answer
44 views

Dynamically convert to a type and perform an operation comparing the converted values [closed]

I have a list of values which are parsed in other place and are populated in the List<string>compareValues list. There is also a ...