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
29 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
147 views

ObservableQueue

I'm looking for feedback on this. ...
5
votes
2answers
164 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
57 views

Security of ProtectedObject

Is ProtectedObject really secure? Otherwise, do you have any advice? ...
1
vote
2answers
62 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
50 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
61 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
98 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
55 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
73 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
83 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
51 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
748 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
63 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
154 views

Reading large file, splitting by new line

I am reading a ~120 MB log file (~300 Million lines of text). ...
2
votes
2answers
227 views
1
vote
2answers
88 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
112 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
936 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 ...
7
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
48 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
136 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
101 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
73 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
86 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
242 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
255 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
299 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
264 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
444 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
81 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
143 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
83 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
107 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
72 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
105 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
232 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 ...
1
vote
1answer
99 views

improve performance of recursive function in c# method

I'm trying to write a function which will cache objects in memory. The function below works, but performance is unbearable. What would you recommend to improve performance? ...
2
votes
1answer
70 views

Validation invoking queries?

I have a question regarding whether it is viable or deemed correct if a validation object invoked a query. Essentially, I have some code that looks like this: ...
3
votes
2answers
180 views

HttpRequest.Json collection - like HttpRequest.Form

I'm looking for a code correctness and best practices review on the following. I created the following in order to prevent using the same code to convert serialized JSON to something more accessible ...
2
votes
0answers
59 views

Resolve (domainless) machine name from DNS alias

So I have a URI with a DNS alias, and I need to I need to dynamically replace the alias with the actual machine. I started out with this: ...
4
votes
2answers
87 views

User Authentication Bundle

I wrote a user authentication program(s) for an MVC application. Before you ask part of the project specs are I have to store user information in company databases on servers that aren't the web ...
2
votes
1answer
45 views

Creating a New User Account

I feel like this maybe to much for one method... This method lives inside of a service class which is called by an interface. It dumps data into three different tables within a database. ...
6
votes
5answers
943 views

Username, Password and UserType Validation

I have two tables in the database: Credentials (userid, password, usertype) Customer ...
5
votes
4answers
448 views

Passing parameters to a query

I have a function that takes a Dictionary<String, Object> as an argument. It uses this Dictionary to create parameters ...
3
votes
1answer
83 views

Populating DataGrids

I'm building an in house query tool. The main form has a drop down which allows the user to select how they want to find scripts, and a drop down for what server they want to run the query on. There ...
7
votes
3answers
135 views

Dataset with optional addition to where statement

I am trying to generate a dataset from a query that has a where statement. If the user passes a value additional things need to be added to the ...