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

learn more… | top users | synonyms

7
votes
2answers
2k views

Efficient mixing of sync and async methods within a single method?

Okay, it sounds odd, but the code is very simple and explains the situation well. public virtual async Task RemoveFromRoleAsync(AzureTableUser user, string role) { AssertNotDisposed(); var ...
14
votes
7answers
3k views

Team member questioning moving from VBA to C#

Background Last year, I was asked to create a tool to be used for business planning for around 10 users. This was done on behalf of another IT team who "sub-contracted" the work to me, and due to the ...
6
votes
1answer
291 views

What is the purpose of Code analysis and when do I need to use it?

I heard about Visual Studio's Code analysis but never used one. I've read MSDN, but still don't understand the real use of Code analysis. Isn't it the same as StyleCop? Somewhere, FxCop was also ...
4
votes
8answers
3k views

What is it called when you set properties on object initialization?

What is it called when you set properties on object initialization? var customer = new Customer() {RequestID = request.ID, AddressID = 5}; Is it considered good practice?
1
vote
1answer
96 views

Using and referencing external executables in a solution

I have an application written in AS3 which I need to be able to start up from my C# application. I have a prototype that does this just fine but my question is in relation to how I would arrange my ...
0
votes
2answers
73 views

What naming convention should you use for data objects solely meant for parameters

This is my pseudocode for DAL: CusOrderDTO GetCustomerOrder(DateTime OrderDate, string customerCode) CusOrderDTO orderSet = new CusOrderDTO() * query data from database, populate CusOrderDTO ...
0
votes
0answers
32 views

Are there any good techniques or libraries for extracting English-like text from unknown file formats [on hold]

My goal is to extract the English-like text from an unknown file format. The files consist of random data (Mixed alpha numerics and other characters) which contains blocks of English text. I want to ...
1
vote
4answers
215 views

How to make one test depend on the results of another test?

Let's say there is a utility class that provides some common static methods used everywhere in your code by many other classes. How would you design your unit tests for the consumers of the utility ...
-4
votes
1answer
121 views

Are there any languages that don't need to be compiled? when dealing with c# [on hold]

Are there any languages that don't need to be compiled? when talking about c# in programming
5
votes
2answers
144 views

How to organize predefined queries with Entity Framework?

I have some queries that I use all the time (like get rows only of some specific type, or count something etc.). I'd like to organize them somehow (better then I currently do). Currently I have them ...
0
votes
0answers
33 views

How is CancellationToken.IsCancellationRequested updated?

I've been doing some refactoring today and I encountered one interesting thing. I've extracted a method from a code which uses a cancellation token passed to it in order to check if the user did not ...
8
votes
2answers
850 views

Is using interfaces for datatypes an anti-pattern?

Suppose I have a various entities in my model (using EF), say User, Product, Invoice and Order. I am writing a user control that can can print the summaries of entity objects in my application where ...
-4
votes
0answers
24 views

Sync Microsoft dynamics(nav) with remote mysql [on hold]

I am very new to dynamics.I want to sync dynamics data with Mysql Databse in my server.So that when ever I enter new data into Nav it should also reflect in my website(which is build with PHP and ...
3
votes
2answers
96 views

Design, how to utilize The Hardware (multiple threads and/or GPU) while indexing (via a database) a very large set of binary files

Problem How can design my file parser to maximize the hardware when processing (creating meta data for) a large file (i.e. how to avoid being blocked by IO and running out of memory) preferably ...
0
votes
1answer
101 views

Styleguide when coding in a static language

I am currently a junior engineer and keen on learning best practices and expanding my experience. My question concerns any static programming language such as Java, C#, C++ etc. When I am writing ...
0
votes
0answers
88 views

Filtering out images that are in the golden ratio

My goal is to detect images that are probably in the golden ratio - by accident, because I take frames from a video that was taken without the intent of having the images in the golden ratio. My ...
10
votes
4answers
6k views

Storing data in code

A few times in my past I've wanted to store data in code. This would be data that seldom changes and is used in places where access to a database isn't possible, practical, or desirable. A small ...
-1
votes
2answers
52 views

Making effective use of SIMD instructions without moving whole app to c++ [on hold]

I want to use SSE2 or similar instruction sets for simd to improve performance in my application. My situation is this: I've written some code for the app in c# but I don't mind porting if it's ...
3
votes
2answers
153 views

When to create a custom exception in C#

I'm writing a class to interface with a simple hardware device over a COM port. The device can configured to use various modes, so my class has a SetOperatingMode function, that takes in an enum of ...
1
vote
1answer
38 views

Event action abstraction and trigger control

I am thinking of abstracting Event action in order to make further alteration/implementation/maintenance easy since the project I am currently working on has volatile requirement. So I thought of the ...
6
votes
1answer
2k views

sqrt c# vs sqrt c++

Any idea why the C# version of sqrt (System.Math.Sqrt) is ~10 times slower than c++ version ? Furthermore, C# version seems to have one extra digit of precision. I have run my test under MSVC2012. I ...
1
vote
1answer
100 views

Portable Data in C# App

I have developed a C# front end app for management of an SQL Database for the purposes of document control. The project this database is for has several consultants and a client spread in a variety ...
7
votes
4answers
1k views

Is it bad practice to make methods public solely for the sake of unit testing? [duplicate]

I have a class with a public method. It has other methods that 'assist' with the purpose of the public method. The public method must be tested. However, I also want to unit test the private methods. ...
0
votes
1answer
37 views

Initialize object from SqlDataReader

As of now, we have two different styles of object intializations based on SQL row in our codebase: public Config(SqlDataReader sdr) { for (int i = 0; i < sdr.FieldCount; i++) if ...
-2
votes
0answers
33 views

.NET MVC Razor with forums [on hold]

I am looking for a forum to add to my site. My site is being developed in .NET with C# MVC Razor. My goal is to use the forums, but importantly, use the underlying functionality to build my user ...
43
votes
10answers
20k views

Is static universally “evil” for unit testing and if so why does resharper recommend it?

I have found that there are only 3 ways to unit test (mock/stub) dependencies that are static in C#.NET: Moles TypeMock JustMock Given that two of these are not free and one has not hit release ...
2
votes
2answers
334 views

Separation of retrieving data and business objects between DAL and BLL Layers

I did some research before posting this question. Among other questions or post, one of those is provided below. I could not get a clear mind how to determine.. Business Objects within a Data Access ...
0
votes
0answers
37 views

Run App on server view on client [on hold]

I have been looking for a way for the last couple of months to run an application on my server while viewing on client. The main reasons for this is that the software needs to be updated regularly and ...
-5
votes
0answers
38 views

I want e-books related to programming [on hold]

I am new in programming world! . I want e-books related to JAVA , and C#.net . Best Regards, Abdulaziz.
3
votes
1answer
240 views

Pattern to use to relate multiple data sources to different user data widgets

I have an client x server intranet application the basically gets data from the server, format it and send that data to the client for display. At the server we are using ASP.NET C# running on IIS ...
0
votes
2answers
87 views

Library design: better to leave potentially destructive feature in with a warning, or cut it out completely?

I recently created a red-black tree in C# to better understand how it works. With it, I implemented an in-order enumerator, however I quickly realized that enumerating a tree can have destructive ...
0
votes
2answers
87 views

Create the fields in class level then instantiate inside methods or create and instantiated inside methods

I'm a newbie in software development. Just wondering which code is better and why should I continue which pattern should I follow. First Snippet: Class TestClass { private Object1 field = null; ...
-1
votes
0answers
34 views

Visiting specific cells of an array

I am trying to implement an algorithm to fill a single dimensional array with the content of the cells from (a,b) to (c,d), (from 0 to `). How could I do this efficiently ? I can't seem to be able to ...
0
votes
1answer
48 views

Lock object in base class: private or protected? [on hold]

I have a base class that contains some lists, queues, and other fields which determine its state. In the base class I only access these fields within a protected lock object since there could be ...
33
votes
4answers
3k views

Why structs and classes are separate concepts in C#?

While programming in C#, I stumbled upon a strange language design decision that I just can't understand. So, C# (and the CLR) has two aggregate data types: struct (value-type, stored on the stack, ...
-1
votes
0answers
50 views

What are the different fields in software/web application development for freelancers? [closed]

For example c# or java is not a field. data warehousing and machine learning are. I'm on my way to become a junior c#/asp.net developer. I'm more interested in backend development and work as a ...
-1
votes
0answers
56 views

C# Semicolon ; End of Line Shortcut [closed]

I'm working in VS.NET 2013 and when I type "(", the ")" is autogenerated so that my cursor (depicted as "|") is located like so: fooBar(param1|) It would be oh so lovely if hitting shift+enter ...
0
votes
0answers
4 views

crystal report to pdf without report viewer [migrated]

i would like to know how to export crystal report to pdf format file without pointing to crystal report viewer in code. below is my working code with report viewer but i would want to do so without it ...
0
votes
1answer
180 views

Strategy for creating a websocket relay?

I own a Raspberry Pi and would like to use it as some sort of websocket relay, so that all people who visit a specific webpage would be able to communicate with each other. The key thing about this is ...
8
votes
2answers
723 views

Any reason behind hyphens in a GUID?

Just when I generated a GUID, I found some hyphens in between the character and also at specified intervals 8b55fec7-c987-4e7b-abad-16e5aaea9b53 Is there any story behind this? Note: My intention ...
0
votes
0answers
14 views

C# gets an enum, but doesn't work correctly with switch statement [migrated]

Im having some trouble with enums and then checking it with a switch statement. I'm not sure if I'm doing something super wrong, but I don't get any errors so hey. # Level.cs enum LevelID { ...
2
votes
1answer
192 views

Reducing the complexity of over-designed code

I have just started working at a company where I have inherited a C# codebase from a previous developer. I know programming well, have an engineering degree + an (unfinished, several year long) PhD ...
0
votes
0answers
46 views

Result with value or error returned from service c# [duplicate]

First of all, let me explain the current situation. In a ASP.NET project, we do some ajax calls to a WCF service. This service always returns a value when called. But this is the way they implemented ...
-1
votes
0answers
29 views

Using Events & Delegates in ASP.NET MVC [closed]

I'm developing a multi tenant n-tier web application using asp.net Mvc 5. In my service layer I am defining custom events for every important action and raising these events once these actions are ...
0
votes
0answers
2 views

How to have only one of two DataGridViewCheckBox columns checked or true in a DataGridView [migrated]

I have a DataGridView with five columns defined. The user populates the DataGridView at runtime by selecting one or more files through an openFileDialog and the file name(s) are loaded into the first ...
3
votes
1answer
129 views

Tracing an object

Suppose I want an object with a list of strings and every method that this object gets passed to adds its name to the list of strings. Basically it's a stack trace, except unlike a stack trace it ...
1
vote
2answers
69 views

Concurrent collections, should read methods allow multiple threads at one time?

I have custom collection and I want to add wrapper to allow concurrent access. public class MyConcurrentCollection<T> { private MyCollection _collection; // passed in constructor ...
0
votes
3answers
153 views

Write a (good) code convention for c# [closed]

As a relative new trainee in my company, I've been asked to write a code convention since the project is 6 years old and nothing have been done. Here's the points I came up with: VARIABLE ...
-4
votes
0answers
44 views

when i'm using 3 tier insertion try-catch, showingstack overflow exception..i'm new to the try-catch block pls help me! [closed]

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient; using System.Data; namespace Wpf_threetier_test { ...
1
vote
2answers
789 views

Database Context and Singleton injection with IoC

All of the below relates to a ASP.NET c# app. I have a Singleton Settings MemoryCache that reads values from database on first access and caches these, then invalidates them using SQL Service Broker ...