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

2
votes
2answers
47 views

Unit testing - How to (or should I) have one assert per test with object comparisons

I've recently read The Art of Unit Testing by Roy Osherove which I found very useful for helping me establish how to define a good unit test. One key aspect of the guidelines Roy puts forward are to ...
0
votes
2answers
89 views

Interface method signature not restrictive enough

I wrote a piece of code at my job sometime ago. While writting the code I wrote few interfaces who would allow me to add more flexibility and at that time I was also trying to understand OOP concept ...
-2
votes
0answers
57 views

Head first csharp book problems. [on hold]

I've just started the Head First C# book and I'm having issues with chapter one unfortunately. If it's needed, I'm using Visual Studio 2012 Express for Windows 7 so I'm doing the book in WPF form with ...
-6
votes
0answers
26 views

how to make a service that has the ability to dump files of a certain folder into the Database using c# [on hold]

how to make a service that has the ability to dump files of a certain folder into the Database using c# ? Plz atleast provide me some logic regarding how to do this ...
2
votes
0answers
103 views

How can I identify a namespace without using a string literal?

My team has a lot of IOC conventions that look something like... if (type.Namespace == "My.Fun.Namespace") { // do stuff } Of course, maintaining this kind of thing becomes brutal after awhile, ...
-2
votes
0answers
36 views

How do I calculate a value from a string in C# when taking data out of a list box? [on hold]

namespace HardwareStore { public partial class frmMain : Form { public frmMain() { InitializeComponent(); ProductBox.Items.Add(new Hardware() { ItemNo ...
1
vote
1answer
92 views

Should classes that define settings and application configuration follow SOLID?

I'm just wondering if you have an application where you define a class that defines some user configurable settings (from an xml file, or a GUI), should you design it so that it follows SOLID as much ...
0
votes
1answer
60 views

Claim based authorization for application framework? [on hold]

I am developing a framework that makes common data management tasks easier for a couple of future applications built on top of it, including document management, data versioning, retention, locking ...
2
votes
4answers
371 views

Algorithm for indexing strings in “list”

Imagine I have file called strings.dat. Inside this file there is alot of string, for example: one million. String are sorted. Now I want to find specified string, so I can write method like this: ...
1
vote
1answer
158 views

How to handle exception in REST API

Given a REST API, which throws an exception when handling a request from a client. Whenever the REST API throws an exception, it's logged and the application (in this case a console application) ...
-1
votes
1answer
52 views

Designing XML - confused between attributes and elements [on hold]

I have to design an xml structure to set standard data exchange with my client. We deal with payments and its related data. At now, my XML data looks like this: <PAYMENTS> ...
-2
votes
2answers
50 views

Has ThreadPool Class changed? [on hold]

I have the framework 4.5 and I'm unable to find the ThreadPool class. Can somebody tell me if it changed or has a substitute? I have not idea why is it missing, according to msdn is supported by 4.5 ...
-1
votes
2answers
227 views

What is the difference between C# and Visual C#?

So let's say I want to start learning C# so I can program Unity with it. I look for a good reviewed book and it says "Learn Visual C#!". I ask myself, what is the difference between Visual C# and C#? ...
0
votes
2answers
51 views

Optimization ended up in casting an object at each method call

I've been doing some optimization for the following piece of code : public void DrawLine(int x1, int y1, int x2, int y2, int color) { _bitmap.DrawLineBresenham(x1, y1, x2, y2, color); } After ...
0
votes
1answer
47 views

Manage ClickOnce releases for different parties

I'm struggling with release management of a piece of software. First some general information: It is a ClickOnce application I follow the release often practice There are about 30 parties served ...
31
votes
3answers
3k views

Are there numbers that are not representable in base 10 but can be represented in base 2?

C# has the decimal type which is used for numbers that needs exact representation in base 10. For instance, 0.1 cannot be represented in base 2 (e.g. float and double) and will always be an ...
0
votes
4answers
447 views

Why do C# developers newline opening brackets? [closed]

I've spent most of the last several years working mainly with C# and SQL. Every programmer I've worked with over that time was in the habit of placing the opening brace of a function or control flow ...
0
votes
0answers
58 views

In memory cache with multiple keys [closed]

I need to build a cache of one of my custom class objects(security as in finance). The object of the class can be identified in multiple ways since it has multiple identifiers like PKey, Name, Long ...
1
vote
1answer
52 views

What is (or where can i find) the algorithm to decode FLAC to PCM?

I'm trying to program a very basic FLAC player using 100% C# completely from scratch. My understanding of this type of thing is very limited, so I'm using this project as a way to learn about ...
0
votes
1answer
76 views

Rewriting code under BSD license

I am currently studding OpengGL with OpenGL Supebible 5th edition. I've found interested for me some C++ code that is distributed with the book (see also on google code). That code is under New BSD ...
-10
votes
0answers
65 views

Avoid anonymous user voting more than once [closed]

I am implementing website about article , now i am going to implement anonymous voting for each article . i maintain one table for tracking article voting this table has the following fields ArticleId ...
0
votes
0answers
62 views

Calls to methods inside an N-Tier Architecture [closed]

In matters of architecture it would be wrong make calls inside the User Interface Layer to methods inside of Business Layer where the methods returns the list of all the elements in some table and ...
3
votes
1answer
80 views

Different scoring algorithms for different competition elements

I am creating a scoring system for a competition that is somewhat obscure, but it resembles the Olympics in terms of its high-level structure. Therefore, I will ask my question in terms of an ...
2
votes
1answer
132 views

Error Handling when no access to Visual Studio or application start point

I've recently joined a project where we are extending the functionality of an external application that our company has bought. It is an Office Add-In with an admin console that allows you to create ...
-1
votes
0answers
43 views

Generate custom unique key in asp.net dynamic data [closed]

I am new to ASP.net dynamic data. I have a column in database (tracking ID) it requires to be generated in a pattern through code i.e "23041401" (the date and a 2 digit increment number). I have tried ...
1
vote
1answer
74 views

Why did Microsoft dropped the RESX model for RESW in Windows Store applications?

Why did Microsoft choose to change the resources management system from .NET's RESX files? RESX had useful code generation, providing developers auto-completion for resources names and outputting ...
1
vote
1answer
42 views

Session states in ajax callback

Someone told me Session or HttpContext.Current.User will return different value when we are working with ajax postback, in case of when the are so many user are live to site. For example, suppose ...
2
votes
0answers
67 views

An efficient way of starting an arbitrary number of consumer threads?

I have a Producer/Consumer implementation where the number of consumers is configurable (this is a form of configurable throttling). The producer and consumer are kicked off like this: var cts = new ...
7
votes
2answers
394 views

Why is there a new() constraint in C# but no other similar constraint?

In C# generics, we can declare a constraint for a type parameter T to have a default constructor, by saying where T : new(). However, no other kinds of constraints like this are valid - new(string) ...
0
votes
1answer
93 views

Application use on website

Is there a good way to run a C# application on clientside in lieu of JavaScript? I have done some front end work with JavaScript and backend C# for web developing at an old job, but I am interested in ...
1
vote
1answer
81 views

Most Appropriate Authentication Type for MVC5 project

I am about to start a new ASP.NET MVC5 project and I am planning the authentication / authorization requirements at present. The client wants Windows authentication, to prevent their users having to ...
-5
votes
1answer
86 views

What are the differences between lists in C# and arrays in PHP? [closed]

I am a php developer and I want to learn some basics of C# but I really can't get my head around how lists work in C#. What are the main differences between a C# List<T> and a PHP array?
0
votes
1answer
60 views

Natural Language to Search Criteria - Date Ranges

Consider an application that stores a set of records that contain: Description Cost Purchase Date I'd like to be able to allow users to utilize natural language to search the dataset. For ...
0
votes
1answer
74 views

Generic object construction - Inherited Classes

Basically I am writing a MSMQ based multi-threaded messaging pattern utility library. It's like a set of components all inherited (directly or indirectly) one class that's called my base component ...
0
votes
2answers
162 views

How to go about saving a Snippet / Block of Code [duplicate]

I am currently learning C#, I am pretty proficient in Java. A project I have been working on for a while is basically an application that lets you input code "Snippets" or blocks of frequently used ...
6
votes
4answers
186 views

Purposely raising exceptions to use catch

For a typical if...else wrapped with exception handling, is something like the following example a recommended practice to avoid code duplication? try { if (GetDataFromServer()) { ...
0
votes
0answers
34 views

Creating New Wrapper Objects and Extension Classes and Keeping it Organized

Here's my situation: I'm programming an embedded device with a very simple, but customizable LED array display. It's 10 RGB LEDs linearly setup. The LEDs will be used to display many different ...
2
votes
1answer
89 views

Accessing a private array when I have an extension method

I'm trying to make a number of data classes for my C#/XNA game, which would essentially be a wrapper around T[,]: public interface IGrid<T> where T : struct { Point Size { get; } T ...
0
votes
1answer
66 views

Advise on loose coupling between user controls

I have 5 user controls on the page and each control implements it's own interface that contains properties and events. In order to enable communication between user controls, I am creating a property ...
6
votes
6answers
1k views

Would a “downcast if block” be a reasonable language feature?

Consider the following "if cast": class A { public void f1() { ... } } class B : A { public void f2() { ... } } A a = foo(); // might return A or B if ( a is B ) { // Inside block, ...
2
votes
2answers
196 views

Is there a point in using closures for non-fully functional programming languages? [duplicate]

Maybe I don't understand closures fully but take for example C#, why would I use closures when I can use classes? Am I missing something? Note that I read this one already but my question is specific ...
0
votes
3answers
71 views

Relative encapsulation design

Let's say I am doing a 2D application with the following design: There is the Level object that manages the world, and there are world objects which are entities inside the Level object. A world ...
2
votes
3answers
393 views

Typical instantiation of new object - is there a way to avoid repetitious syntax?

When learning C# (and OO concepts more generally at the same time) something I found very distracting is exemplified by the following line: ExampleClass exampleObject = new ExampleClass(); It's the ...
0
votes
0answers
64 views

How to design socks proxy server (OOP)

I'm working on a socks server application written in C#. But I don't really know how to design this in a nice way. I got this for Socks V4 and V4A: I'm not sure if it clears things up, but I think ...
2
votes
0answers
47 views

how to process document state transition?

Imagine there is an application (ASP.NET MVC) that processes some documents. The document must be revised several times by different group of users. state/role rules: simple user can only publish ...
-1
votes
1answer
195 views

How to make C# methods work like javascript functions? [on hold]

I'll keep it simple, I want to make C#'s methods work like javascript's functions. Mainly so I can convert this - function makeVariable(terp) { var me = {value: 0}; return function () { ...
1
vote
1answer
88 views

alternate approach of binary serialization/de-serialization

Is it possible to convert a list of object directly to byte[] (and vice versa) to gain performance (by avoiding serialization/de-serialization)? What I have in mind is that a list is somewhere in ...
0
votes
3answers
207 views

How to design an IDisposable that unconditionally needs to be disposed?

Consider a class that implements IDisposable, and that has members in such a way that it will never become eligible for garbage collection when it is not disposed. And as it will not be garbage ...
-1
votes
1answer
48 views

assembly.GetTypes() vs assembly.DefinedTypes.Select(t => t.AsType());

public static IEnumerable<Type> GetAccessibleTypes(this Assembly assembly) { try { #if NET40 return assembly.GetTypes(); #else return ...
0
votes
1answer
58 views

Modifying XML documents using deserialization/serialization VS LINQtoXML and XPATH [closed]

I have XML documents that I need to modify, I also have the XSD schema that defines their structure. What I did was this using XSD.exe tool I create class object from the schema in program ...