Tagged Questions

.NET is a software framework supporting a multi-language paradigm and supporting language interoperability. .NET applications are executed in a virtual machine (CLR) which provides a few important services: security, memory management and exception handling.

learn more… | top users | synonyms

2
votes
1answer
60 views

Is this the correct usage of ConcurrentDictionary<TKey, TValue>?

I need to make a simple class that tracks how many clients are listening to a specific item, will be referred to as building hence forth. I will have a timer running that will check which buildings ...
2
votes
1answer
58 views

Null checks in view

It's really a nitty-gritty issue for me, and I have been here many times before. How could this be improved? I have a basic viewmodel for a view: ...
3
votes
2answers
174 views

Get missing sequential numbers from array

I have an array like Original = {1, 2, 3, 6, 7, 8, 9, 10, 12}. After removing some elements like Delete = {6, 7} from it, I want ...
0
votes
2answers
75 views

Connecting to a MySQL database with C#

Can anyone help me with checking this code? It is for connecting to a database. The method getFromDatabase is to take values from the database and put it to a ...
4
votes
2answers
100 views

.NET REST API JSON Filtering

My question, REST API and lazy loading objects, didn't receive any answers (or many views), so here is my attempt at the solution. Problem overview: My mobile app requests a list of objects through a ...
3
votes
0answers
18 views

Tuning Excel calculation engine which uses MS Excel interop

I am currently building an Excel calculation engine. It's purpose is basically to wrap the calculation logic of an Excel workbook in order to use the logic from a C# library. ...
10
votes
2answers
133 views

Embedded C# bitpacked arrays to low-level STM32F4 driver for GE G35 RGB LED Christmas tree light

I'm going to be opensourcing some code I'm working on. I don't need help with the code, I just want to make sure my code is readable and my comments make sense. I have a knack for the esoteric. ...
4
votes
2answers
389 views

Code organization for .NET solution

I am going through one of my class library projects, and while nothing is wrong with it, I am finding myself being a bit anal, and wanting to organize things a bit differently. The project in ...
1
vote
1answer
56 views

Work with nested task [closed]

I have Client and Server classes. The Server return a ...
0
votes
0answers
29 views

From multiprocess to multithreading [closed]

I recently joined a team responsible for the enhancement of an existing 5-year old program. It was developed with multithreading in mind, but not correctly implemented. The solution is composed of ...
2
votes
1answer
34 views

Implement interface type in implementation of another interface without too much casting

I have a group of tests that must be run in similar (but different) fashion and they have setups, results, etc. which are also similar but different. Great, I thought, I'll use interfaces to define ...
3
votes
3answers
164 views

ObservableQueue

I'm looking for feedback on this. ...
5
votes
2answers
184 views

Proper usage of “using” statement in base64 encode method

I used the example on here, but with little changes in order to write a base64 encoder method. I have a few points about the code: I would like to use using ...
1
vote
1answer
62 views

Security of ProtectedObject

Is ProtectedObject really secure? Otherwise, do you have any advice? ...
1
vote
2answers
83 views

Logger facade code for configuring multiple loggers are runtime

Following is the code for a logger facade that I have created, which can be used to log via any of the standard and configurable loggers like log4net, BitFactory, currently I have just integrated ...
6
votes
2answers
56 views

Buffering of fast changing datapoints or events

The following class implements a buffer which captures fast changing datapoints or frequently raised events and dispatches them in batches. It will asynchronously call a processing function for the ...
1
vote
1answer
70 views

Performance issue in .NET remoting

I can't understand why this strange behavior when I call the method remotely is expensive. I have observed a performance issue when my object method called remotely compared to when it's called ...
7
votes
3answers
1k views

Replace each whitespace in a string with “%20”

My implementation: ...
3
votes
2answers
114 views

Implementing faster StringBuilder that only works with ASCII strings

I wrote a StringBuilder that works only with ASCII strings. the current append performance is almost identical to BCL StringBuilder append performance. I want some tips on how to make it faster, and ...
2
votes
0answers
58 views

Supporting Enum in EF 5 with .Net 4.0 (Visual Studio 2010)

I'm currently working through Getting Started with EF5 using MVC 4 in Visual Studio 2010 (.NET 4.0) to learn about how to use ASP.NET and Entity Framework. During the beginning of the tutorial I ran ...
5
votes
2answers
79 views

Secure password hashing implementation

I'm implementing a password hashing method for a website. The code below is part of the User class. Any pointers on what I could do better? ...
3
votes
1answer
92 views

Efficiency of nested LINQ foreach loops

I've been working on an older project with framework is 3.5 as the target. There is a new user control that displays a list of data from a web service. I hit the web service (Soap/XML) and deserialize ...
2
votes
1answer
68 views

Implementing ViewModel design pattern using DI in a MVP-VM architecture

Based on this answer: MVVM implementation using C# and XAML, I understand that my ViewModel is some kind of a wrapper for my Model. Being a fan of DI and SOLID principles, I have made my ViewModel ...
4
votes
2answers
51 views

Determining if a discount is valid for a product

I'm in the process of re-writing a method I've come across in our code base. It's pretty lengthy and a lot of it seemed redundant. It's a Discount object class ...
10
votes
5answers
786 views

Is this Repository Design Pattern Valid and efficient?

I am using Dapper ORM in my Data access Layer, but I think analysis of the code below doesn't depend upon any specific ORM. What should be the single common place throughout the entire Data Access ...
4
votes
2answers
67 views

WCF service implementation

I have WCF Service using .NET 4.0. I have similar methods, similar code and I want use good patterns for improvement the code for get high level quality. I want reuse code, maybe using ...
5
votes
1answer
171 views

Reading large file, splitting by new line

I am reading a ~120 MB log file (~300 Million lines of text). ...
2
votes
2answers
241 views
2
votes
2answers
98 views

Idiomatic and Conventional F#

As of late I have been learning F#. Today I accumulated what I have learned so far to develop my first program - a script that counts the number of lines of code in a given Visual Studio project. ...
5
votes
1answer
124 views

Optimizing FirstOrDefault

I'm working on an application in which it takes quite a bit of time to initialize the data. Some background: I'm creating a sort of pivot table in which I turn Figure 1 below into Figure 2. I've ...
10
votes
5answers
947 views

Using TryXXX pattern to avoid exceptions

I have been using the TryXXX and GetXXX pattern lately to give clients a choice whether to trap an exception or to read a boolean. An example of this concept would be ...
8
votes
5answers
2k views

One-shot events in C#

I have a class that performs some long-running operation. This class exposes a Completed event. I'd like clients that use this class to register to get notified ONLY ONCE when the class completes ...
1
vote
0answers
51 views

Separation of concerns for security checks

I needed a nice typesafe way to implement security checks for various domain objects and actions that can be performed on them. I had an idea how to do it, so I implemented it as a simple proof of ...
4
votes
1answer
177 views

Creating Thread safe list using Lock object

Will this code qualify for a truly thread safe list? It is using the Lock object. ...
1
vote
1answer
163 views

Creating Thread Safe or Concurrent List [closed]

Can a thread safe or concurrent list be created using the code mentioned underneath, where I wrap all the calls to the base class in a ReaderWriter lock. I can similarly implement all the public ...
5
votes
1answer
84 views

Renaming numbered files for proper sorting

I have designed a tool that generates some HTML files and a CSS file in a directory, which then feed into a tool called Jutoh that uses these to make eBooks. However, my output files are of the form ...
5
votes
1answer
88 views

Iterate through dynamic levels [closed]

I have the below function that works and cycles through 3 possible levels. Is there a way to do the same as the function below but not have to do the multiple ...
4
votes
1answer
89 views

Unusual comparison of object and string

I have a pretty unusual situation (please, don't ask why) where I need to compare objects which might be a string or double to ...
7
votes
1answer
244 views

Somewhat esoteric if statement in a paginated feed

I am working on the home page of a website that will have a paginated feed (much like a blog's home page). One of the requirements is that when a user navigates to a non-existent page, he or she will ...
10
votes
2answers
267 views

Set desktop background

I created a simple program that downloads an image (different image every day), then sets it as my desktop background. I feel like the lines of code can be cut down significantly while still remaining ...
6
votes
1answer
423 views

Reducing memory footprint of ReportViewer

We have implemented a process using C# and ReportViewer to create PDFs by the LocalReport.Render method. When we have to process ...
6
votes
3answers
287 views

Throwing exceptions when validation fails

When I want to check the validity of an attendance being entered into the system, I perform following action. AttendancePresenter Class ...
6
votes
5answers
590 views

Transaction handling for multiple SQL statements

In this code I update two tables called Payment and SalaryTrans. First I insert records (Salary payments) to ...
3
votes
2answers
128 views

Implementing WCF method that supports either string or object as a method parameter

I have the following contract in a WCF-based web service: public List<string> GetAllPossibleQueryEngineHostNames(Instance instance); Obviously, I can call ...
1
vote
1answer
250 views

Access View from current/corresponding ViewModel

Sometimes when developing a WPF application, I need to access a certain Window (View) from the corresponding ...
1
vote
1answer
93 views

Async function with slow web reference(web service) slowing down webpage

Is there a way to make a threading/async post with a web reference not slow down the whole website just because the web reference takes a long time to return a response? I have a send email function ...
3
votes
1answer
125 views

Data Access Layer method with transaction handling

I just want to know whether I've done transaction handling well. Also what about the other types of transactions available in .NET with regard to this code snippet? Also are there any redundant ...
1
vote
1answer
73 views

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

As part of a C# class CsvConverter that converts various file types to CSV, I am designing a private class CsvConversionResult. ...
3
votes
1answer
121 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 ...
3
votes
3answers
286 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 ...