Questions tagged [.net]

.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.

Filter by
Sorted by
Tagged with
7
votes
2answers
4k views

Implementing IDisposable correctly to return TCP connection back to pool

I'm trying to implement TCP connection pooling and return a connection back to the pool using IDisposable. I'm wondering if my implementation is correct. It seems ...
8
votes
2answers
2k views

Attribute driven behaviour in C# methods

We want to create a TransactionScope factory class that we can use as a central point for instantiating TransactionScopes with ...
4
votes
2answers
9k views

Multithreaded item-processing queue

I have this Queue declared in my class: static private Queue<SignerDocument> QUEUE = new Queue<SignerDocument>(); ...
3
votes
3answers
5k views

Attempt to calculate age in VB.NET

I am working on an app where I have to calculate the age of a person. Inside of my age class I have a function that is designed to account for leap year. Is there anything I am missing or could ...
3
votes
1answer
9k views

Query String Serializer

I have a ASP.NET Web Forms project, and I want to build calls to .aspx pages in a strongly-typed fashion. I ended up rolling my own serializer that takes simple structs and saves them to/loads them ...
3
votes
1answer
184 views

C# expression evaluator review request

I successfully created an expression evaluator in C#, and I would like to know if it works well, and what I can do to improve it. ...
2
votes
1answer
2k views

Loading XML and csv files to datatables at startup

Here is some code that I put together for an app I am working on that loads 2 XML files and a large CVS file to a dataset at startup. It runs fairly fast, but I would like a second opinion on what I ...
1
vote
2answers
178 views

Inheriting needed when only difference is performed in the constructor?

I have a class that produces a key based on the two objects passed. The key for the items passed is simply the string of the ID (a GUID) for each object. There is also a subclass that makes sure any ...
5
votes
3answers
32k views

Is it a good way to get Count on Linq?

...
4
votes
2answers
2k views

Producer/Consumer queue

I use this class for scheduling bits of work on a single thread. Work can be scheduled to be executed immediately or at a future time with the use of timers. It has many producers (the work adders) ...
2
votes
2answers
4k views

Syllable-counting function

I was working on a syllable counting function for a text editor(this function is accurate enough). However, I would like to know if it is possible to optimize it, it already separated into another ...
1
vote
2answers
34k views

Inserting Data in The Database using LINQ TO SQL

Can this Code be any shorter? because it seems it is very long with just simple insertion of data using LINQ TO SQL ...
3
votes
1answer
700 views

Review an asynchronous/message-oriented library actor

I'd like to get input on a F# actor that coordinates receives around a blocking message buffer. The actor is a piece of code that continuously tries to fetch messages from Azure Service Bus. ...
4
votes
7answers
587 views

Check assistant's password

I have two more methods the same as this except that they query a different table. Is there another way to know if the result of the query is null? The ...
3
votes
2answers
1k views

Is the solution design optimal? C# 3 - Tier

I have the following solution structure. This is a business domain (for an amount transfer operation in bank account) which will be called by a WCF service. Is the solution structuring correct? Data ...
3
votes
2answers
2k views

Retrieving a user's password for verification

I am working on a log in form. Basically, my code searches for a user name, then retrieves the hashed password that is related to that account. It then converts that string hashed password then ...
8
votes
1answer
2k views

.Net TCP Server

I saw this question "Is this implementation of an Asynchronous TCP/UDP Server correct" and it is very similar to what I want to do but it goes about it in a different way so I am wondering if anyone ...
3
votes
1answer
181 views

Quickly updating a mass of objects

...
2
votes
1answer
1k views

How do I make this C# code more efficient, in terms of FPS and time complexity?

...
11
votes
3answers
2k views

Can these unit tests be improved?

I'm not the greatest at writing tests yet and I'm starting a new OSS project for learning and as part of it I want to tackle being more effective at writing tests, more specifically quality tests. I ...
3
votes
1answer
8k views

Data to FTP upload by stream copy

I'd like to check the following process relating to the uploading of data by FTP, after the data is read from a database. I have a stored procedure that returns data in the following pipe delimited ...
3
votes
1answer
2k views

Refactoring legacy code for unit testing

I'm trying to refactor some code for unit testing and was hoping you could critique it. This is the original method: ...
8
votes
2answers
8k views

SocketAsyncEventArgs send and receive

I been working on getting the SocketAsyncEventArgs to work the way I want it to work. Now I was wondering: is this going to work how it should work? ...
6
votes
1answer
3k views

Deleting folders is a risky business

Deleting folders programmatically is extremely dangerous. It is enough for somebody else to change a configuration file or constant variable including the target folder's name to, say C:\, and that's ...
1
vote
2answers
1k views

Refactoring different type of param to reduce duplicate code

So say I have a method that does a bunch of stuff, and I want to refactor this method to take a different type of parameter: ...
2
votes
3answers
110 views

Page_Load-routine

I have the following .net-page. I hope it is ok that it is only an example, describing my problem(s) pretty well. ...
2
votes
1answer
2k views

Is this a good example of Reactive Extensions? How can I make this better?

...
2
votes
2answers
1k views

Trace-like extensions for unit testing

Below is a set of extensions that I use in unit tests. The basic idea is that when creating or modifying some sort of user output type of string, I want to eyeball the output to see that it makes ...
3
votes
1answer
1k views

Variable parser for the Hack programming language

I am optimizing the variable parser for my programming language, and also trying to make it more readable and concise (precedence: readable and concise > efficient). What is the best way to improve ...
4
votes
1answer
472 views

Find log4net logfiles at runtime without adding dependency to project

I was searching for a way to get all active log4net logfiles (if any) at runtime without adding a reference to the project. This is the solution I came up with: ...
3
votes
1answer
230 views

Capturing a string in a specific format

I have a requirement to capture a string in a specific format of * [Numeric Digits] *. This is how I have done right now but I think it would be faster with Regular ...
3
votes
4answers
22k views

Checking datasets for tables and rows [closed]

Is there a cleaner way of checking a dataset for tables/rows before attempting to read them? ...
4
votes
4answers
6k views

Action queue in .NET 3.5

Because I needed to execute some actions one by one in seperate thread (not to block GUI) and I couldn't use Task.ContinueWith from .NET 4.0 I decided to write it ...
9
votes
2answers
1k views

Helper class for Null and Empty checks

I have some static helper class: ...
1
vote
2answers
6k views

Replace all occurrences with the properties of an object

The basic idea is to replace all special expressions, e.g., [%InvoiceNo%], [%DueDate%], in a string with the properties of an ...
3
votes
1answer
1k views

Providing factory method to Lazy<T> when factory exists on another lazy instance?

The Problem I found myself needing an instance of an IObjectContext interface that should never be null, but wanting to delay instantiation until after some ...
3
votes
3answers
6k views

Best C# idiom to convert the items on an object array to a string?

I have something akin to ...
1
vote
2answers
1k views

Querying .NET DataSet and ignore rows that contain NULL

I've written some code to read a column of data from a dataset called AltIds. The values are nullable. My code is written to find all the values in the column ...
3
votes
1answer
245 views

C# asp.net project functionalities

I just started working in a project that wasn't developed by me, I'm worried about some of the functionalities and I would like some suggestions. After the login validations, the login procedure is ...
13
votes
4answers
46k views

Test connection to database C#

I've created a small method to test the connection to a database: ...
2
votes
3answers
2k views

Calling stored procedure with a sqlCommand

I have the following code as part of an sqlCommand which is calling a stored procedure: ...
33
votes
3answers
48k views

Entity framework with repository and Unit Of Work pattern and POCO architecture

This is my architecture to EF4 using repository pattern and unit of work pattern with POCO. I believe I made some mistakes. I have a solution with 5 projects: ...
11
votes
3answers
1k views

Reusing strings read from I/O

I am working on an application that reads lots of data from the network and puts it in a grid. I noticed that I could save some memory by reusing existing strings instead of always using the new ...
14
votes
2answers
15k views

Listing the weeks in a given month

I need to take a month (defined as a start and end date) and return a set of date ranges for each week in that month. A week is defined as Sunday through Saturday. A good way to visualize it is if ...
2
votes
2answers
11k views

Importing XML to a database using LINQ to Entities

I am importing XML data to a MySql database using LINQ to Entities. The data represents which students are in which classes, and looks like... ...
3
votes
1answer
1k views

Merge entities which have the same children

The C# code below, using LINQ to Entities, aims to merge all Class entities which have the same SubjectId and the same ...
5
votes
1answer
4k views

Convert .NET DateTime to a string using ordinals

With a DateTime object, it's easy to get, for example, 11 October 2011 by using: d.ToString("d MMMM yyyy"); However, there ...
8
votes
1answer
29k views

Creating a TreeNode hierarchy in C#

The following function accepts a list of Topic entities, retrieved from a database using LINQ-to-Entities. Each Topic has an Id, ...
6
votes
1answer
2k views

Trying to create a robust task execution engine

I've created a simple asynchronous execution engine and I would like some help identifying places it can be improved. The basic function of the system is to monitor MSMQ and Service Broker queues and ...
4
votes
2answers
1k views

Is calling file write in the dispose acceptable?

...