.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

1
vote
1answer
42 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
20 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
62 views

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

As part of a C# class CsvConverter that converts various file types to CSV, I am designing a private class CsvConversionResult. ...
2
votes
1answer
45 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
105 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
38 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
56 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: ...
2
votes
2answers
59 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
29 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
53 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
31 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. ...
5
votes
5answers
434 views

Username, Password and UserType Validation

I have two tables in the database: Credentials (userid, password, usertype) Customer ...
5
votes
4answers
111 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
56 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
112 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 ...
2
votes
1answer
60 views

Avoid redundancy of HTML entities in .NET framework

I have to store various HTML named character references for the following purposes: Escaping special characters myStringBuilder.Replace("À", WebHelper.Agrave) ...
1
vote
1answer
41 views

Update multiple records with Entity Framwork

I am wondering what the best way to update multiple records with Entity Framework is. This is how I normally do it, and it does work: ...
8
votes
4answers
462 views

Find if value exists using SQL True/False Return

Aim: To Assess if one, or more, examples of a value exists in a Database in the quickest time as I only needs a True/False result. The variable is Alphanumeric. Question: Is this the quickest and ...
2
votes
1answer
41 views

Binding data to a ComboBox and then showing ValueMember in another TextBox

I have a comboBox and a TextBox in the View and when the view is loaded, the ...
3
votes
0answers
48 views

Binding a DataGridView to a List

I'm new to Databinding in MVP and I want to bind my DataGridView to a object list. This grid may be populated in two ways. There are TextBoxes in the form and users can enter text, and when they ...
3
votes
1answer
37 views

Optimisation XML handling within vb.net application

I need to optimize this snippet to be faster: ...
22
votes
3answers
2k views

What are the best practices with multithreading in C#?

For a while I have been interested in seeing if some tasks work well when split across multiple threads. On the one project I have been busy with I have been creating a lot of small utility apps, to ...
6
votes
5answers
1k views

Regex validation for Email Address

I need to validate whether my regex is correct for below scenario. Suggestion's if the regex is correct: Wiki Link Local_part The local-part of the email address may use any of these ASCII ...
3
votes
3answers
70 views

Validating a string under few conditions

Following code validates NIC number of a person (National Identity Card, no like SSN) Requirements are... Length should be 10 digits or characters All should be digits except the last one Last one ...
2
votes
1answer
45 views

Using a single validation handler for all controllers in a form

In input validation I'm using this validation method in my all Forms. Here I have a single handler for all TextBoxes in my Form and if I have other controllers like ...
5
votes
2answers
69 views

Convert string to multiline text

I made this method that takes any string and transforms it into a multiline text l; each line having the max (character) length specified by the rowLength ...
3
votes
4answers
162 views

Input validation for text boxes in a Form

In a Win Form I'm doing initial validation in the Form. So before saving data, I want to validate whether all the required fields are filled (Text Boxes) by the user. There are about 18 such Text ...
4
votes
1answer
149 views

IndexOrDefault that functions like FirstOrDefault

I don't know why this is not in the .NET Library, but I need to be able to use an index against a list and not have it throw an exception if it is outside the bounds of the list. This is what I came ...
2
votes
1answer
68 views

Calling a copy constructor in Presenter to prepare a list of Models

I'm new to MVP. In a presenter I have following code. Here what am I trying is to create a list of Model objects (in this case ...
3
votes
1answer
57 views

Exception handling with expression lambda in Presenter class

Following is a code snippet from MVP Win Forms application. My DAL doesn't handle exceptions and it will be propagated up to the calling method in the presenter classes where the exception will be ...
2
votes
0answers
68 views

Possible memory leak with WPF Custom Control?

I might have a potential memory leak with my custom control. Do I actually have one? ...
4
votes
1answer
43 views

Follow Up post: Proper handling of exceptions in MVP

This is a follow up post of my early question "Proper handling of exceptions in MVP" So based on the answers I re edited the post and now my exception handling code looks like this... DAL ...
6
votes
2answers
319 views

Proper handling of exceptions in MVP

In my DAL currently I'm handling exceptions as follows. Is it in an acceptable level? Note : I'm using MVP in this Winforms application. ...
3
votes
0answers
53 views

Using a UserPermissionService by all Presenters in the Application to control the access to commands

I'm handling user permission in a MVP Winforms application as follows. Here I'll give a full detail of my code as it will be helpful when answering to this question. My user model has a list called ...
3
votes
2answers
178 views

Text parser code elegance

I have a text parser that reads certain information from a given file with a specified format. The text file contains some measured properties of a product. The date model number/lot number is written ...
1
vote
1answer
37 views

Inheritance or DI in Presenter classes in MVP [closed]

In MVP pattern we can use DI when our presenter classes need services as follows: ...
5
votes
1answer
74 views

Combining List<>.ForEach and List<>.Zip

I have three lists, and I need to operate on the ith element of each list simultaneously. ...
2
votes
1answer
73 views

User name and password validation in a MVP application

In a WinForms application I'm doing the password validation as follows: When the user presses the OK button after entering username and password, an event will be fired and the listener in the ...
1
vote
2answers
60 views

Controlling permissions in a MVP application

In a Windows forms payroll application employing MVP pattern (for a small scale client) I'm planing user permission handling as follows (permission based) as ...
4
votes
2answers
68 views

Sorting and search List with Icomparer

I would like to ask for code review for my project related to sorting and search C# lists with IComparer on objects. I expect some design tips and how to make code ...
5
votes
2answers
89 views

Unit Testing an AppInfo class

I have never written a unit test and I am really new to C#. I am attempting to test a method, am I testing for the right things here? The Method ...
6
votes
5answers
165 views

Function for formatting a timespan with optional trailing zero

I'm looking to achieve a time format that looks like this: 2d 4h remaining; or 1h 36m remaining; or 35s remaining, etc. So that it only displays the two largest values of time (this is how Clash of ...
7
votes
3answers
233 views

Is there a simpler way to format this timespan?

I'm looking to achieve a time format that looks like this: 2d 4h remaining; or 1h 36m remaining; or 35s remaining, etc. So that it only displays the two largest values of time (this is how Clash of ...
3
votes
3answers
433 views

Beautifying Dates

There has got to be a better way to do this. I have a method which returns either your standard "01/01/2014" Date or "January 1st, 2014" Date of the assembly file write time. Any suggestions on ...
7
votes
1answer
115 views

Fluent Nhibernate, is the mapping correct?

I'm very new to NHibernate and DB. I have three tables which are connected with many to many relationship. Here are the tables creation Script: ...
5
votes
1answer
81 views

Adding groups to ListView depending on the data in a list

I have written simple code which loops through a list object and create groups in ListView depending on the data in the list. I have a list object of type ...
4
votes
2answers
104 views

DAL Returns a collection of business objects in MVP

In Model View Presenter (MVP) pattern, it is said that our DAL always should returns business models. If I want to get a list ...
3
votes
2answers
203 views

Slow data-processing and inefficient memory usage in .NET containers

I am writing a text classifier and in order to do so I need TF/IDF values per every word of my signle text. Then I need to use the cosine similarity: \$similarity = cos(\theta) = \dfrac{A \cdot ...
9
votes
1answer
128 views

My first multi threading class

I've thrown everything I can at this, and I can't get it to lock or crash. My hope is that I have applied the principles correctly. I write client apps in JavaScript, and this is only the 3rd .NET ...
5
votes
1answer
87 views

Generic Converter framework

I find myself frequently converting between formats so I have come up with the following conversion framework: The converter interface surfaces a method to convert from a source type to a target ...