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

5
votes
4answers
128 views

How to convert the following node evaluation procedure to a non recursive solution?

I have the following recursive method. It evaluates a node (that represent a logical expression), using deep first search traversal : EvaluateNode(Node node) { bool result; switch(node.Type) ...
1
vote
1answer
165 views

Using “Return” over “Break” or a combination

When using the Switch statement, is using return instead of break or a combination of the two considered bad form? while (true) { var operation = Randomness.Next(0, 3); switch (operation) ...
4
votes
1answer
176 views

Derive from a base class but not include a condition in the base class's method

The current code looks like this: public class Details { Public void Populate() { WriteChapterDetails(); } public void WriteChapterDetails() { if ( ...
1
vote
1answer
109 views

Does snapshot change tracking break DDD principles?

I'm building a website with MVC 5 and Entity Framework 6, implementing the Unit of Work & Repository patterns, and - for flexibility and performance - would like to utilize Entity Framework's ...
0
votes
2answers
61 views

How to store users' info in network app?

I'm currently working on a school project that aims at creating a P2P chat client for users on the same network. For now, it will only be used by users on the same LAN network. But hopefully,I will to ...
0
votes
1answer
101 views

Algorithm for merging multiple rows of data

I need an algorithm to merge multiple rows for data, where one column is the index column and if one or more rows have the same index value merge the column values into a single row, and lastly sort ...
0
votes
1answer
25 views

Bundling style and script files in asp MVC layout page

How to bundle style and script files using layout in asp MVC? Here is an example. Layout1 uses style and script file for header and footer functionality. Sections are declared. View1 uses Layout1 . ...
0
votes
0answers
26 views

ObservableColection and Animations in EventHandlers

Background I'm writing a Windows Store app in C# / XAML that incorporates multiple ObservableCollections. The elements in these collections subscribe to a number of Events to start a variety of ...
0
votes
1answer
41 views

WCF Project Structure & Maintainability

We are working on a medium scale WCF project configured to use per call instancing and wondering weather it's a good practice to create classes per service method to hold the business logic since each ...
-2
votes
2answers
89 views

which is a better practice one method that does everything or a series of different methods?

I'm working with asp.net and c# Lets say I have a bunch of drop-downs and I want to bind data from a database, is it better to make a master-bind method that loops each one and gets the parameters to ...
-1
votes
0answers
35 views

how to use MessageBox in C# , i tried to used its button parameter [migrated]

I try to write like this : MessageBox.Show("Request is Online process!", "callback ,tips",MessageBoxButton.OKCancel) .but it said there is no MessageBoxButton exist in the context .how can i solve ...
1
vote
3answers
95 views

Single instance of windows service querying multiple databases

My current situation is that we have four instances of a single windows service running on the server, for production, demo, QA and dev. I am looking for a solution where I just need to run single ...
0
votes
1answer
113 views

Is brevity in writing code beneficial when it requires using language constructs in a strange way [duplicate]

In C#, with extension methods, you can replace this line of code: TimeSpan interval = TimeSpan.FromMinutes(4); with this one: TimeSpan interval = 4.Minutes(); Extension method being: public ...
-3
votes
0answers
27 views

Simple issue writing from array to text file after storing what I have read as array and editing one of the arrays [on hold]

Simple issue with writing back from array to text file after storing what I have read as array and editing one of the arrays. I need to write all the information back from the array into the text ...
-2
votes
0answers
44 views

c# chat app only working on local network [on hold]

I made a chat app in C# using the UDP protocol, I don't want to use TCP. But it is only working within my own network/wifi. I made this for myself and my friend, or possibly anyone else who downloads ...
-2
votes
0answers
49 views

ASP.NET the correct technology? [on hold]

We currently have a 'dashboard' application written in Python, which does/has the following things: It basically controls 'Jobs' which are XML files. It is an application that sits in the system ...
8
votes
1answer
322 views

How to avoid chatty interfaces

Background: I am designing a server application and creating separate dll's for different subsystems. To simplify things, let's say I have two subsystems: 1) Users 2) Projects Users's public ...
1
vote
1answer
48 views

Stateless Web Applications Defeat DBContext Somehow?

In Entity Framework, the DBContext class is said to implement the unit-of-work pattern. As I interpret this, it means that if you make a DBContext, manipulate its data, and then dispose of it, then ...
2
votes
1answer
78 views

Managing types and conversions in a compiler

I am trying to determine how to manage types and conversions between types within a compiler that I am writing. The compiler is being written in C#. There are a number of different kinds of types. ...
0
votes
0answers
21 views

Using Streamwriter to write to a specific place in a text file [closed]

I am trying to write to a specific position in a file. In the previous windows form I have selected a person to play with. In the file you will have three lines then a blank line then new player etc. ...
2
votes
1answer
44 views

SOA principles, encapsulation and autonomy

We are developing multiple web services in C# using WCF, but we´re new doing it. So, for what we have read and learnt, this is our approach: We have a class library that we called CommonLibrary ...
-2
votes
0answers
26 views

Plotting SQL Data on the web [closed]

I am working on a project where I need to plot data from an SQL server onto the web. I am a complete beginner when it comes to this, and was wondering if I could get some help or general advice. I ...
-3
votes
0answers
48 views

Dynamic report/data manipulation with pre-selected tables & columns using EF [closed]

Please consider this is my company's requirement. Our team is in the final stage of developing the company's enterprise web application as an Asp.Net MVC + EF5 Web application. They assigned me to ...
-3
votes
0answers
27 views

Suggestions for Subscription-Based Software Product Licensing [closed]

Can anyone suggest some solutions or products for doing subscription-based software product licensing? We have used dongle-based solutions in the past but, with the proliferation of virtualization, ...
3
votes
1answer
95 views

Algorithm to assign edges to smallest possible polygons?

I'm designing a procedural city generator, and the first step of the generation process is the creation of city streets. These streets extend out in a straight line to a point, then they can either ...
0
votes
3answers
216 views

Using SQL queries in loops

Is it a bad idea? I need to compare each entry.Key value in a Dictionary of strings to a SQL table. If there is a match, then I pull the data from that row. I was originally going to use a foreach ...
0
votes
2answers
155 views

Check all “lines” in an array?

I have a 3D array with booleans and I need to check if there are "lines" that all contain true or false. With lines I mean horizontally, vertically and diagonally within the array. However I only need ...
-3
votes
3answers
168 views

What exactly are benefits of Method Overriding in C#? [closed]

What is the advantage of method overriding since we can always create entirely new method with different name? The only advantage of overriding is you get flexibility to use the same name of method?
0
votes
1answer
60 views

How can I decouple query and context in a “query object” scenario?

I'm using a query object pattern (similar to this) to manage disparate queries while avoiding bloaded facades/repositories. A query object takes a number of constructor parameters, representing query ...
11
votes
3answers
467 views

What is the best way to structure and name files which contain generic classes with the same name?

In my current project I have come across the requirement to create generic classes with the same name, but different numbers of generic parameters. For example: MyClass<T1> MyClass<T1, ...
2
votes
2answers
181 views

Database performance comparison

I have been tasked with moving from a MSSQL backed database, entity framework code-first, wcf service based MVC application to a MySQL backed database. I have had being trying to find a performance ...
1
vote
2answers
212 views

Is there actually an advantage to using Win API calls for file access?

I remember coding file access using the Win API about 15 years ago. It was much faster than using the FileStream of my language at the time (Delphi). I spent a while today experimenting in C# under ...
1
vote
1answer
114 views

.NET WCF: Persistent connection or Open/Close as needed?

I have a .NET WCF web service currently running in production right now. I would say 95% of the time it works flawlessly and as intended. However; there are times when I am throwing an exception that ...
-1
votes
0answers
23 views

How to find a specific Element in a UserControl? [migrated]

I have a referenced UserControl and want to find a specific child element in C#. This is my UserControl: <UserControl .. > <Viewbox> <TextBlock>Text</Textblock> ...
0
votes
3answers
137 views

Using conditions again and again or just create different methods [duplicate]

I have a method, function DoThis(bool isHuman) { // Do something if(isHuman) { //call his dad } else { //its a animal - let animal resuce know } // add some blah blah code ...
13
votes
7answers
2k views

Is there a pattern for a more “natural” way of adding items to collections? [closed]

I think the most common way of adding something to a collection is to use some kind of Add method that a collection provides: class Item {} var items = new List<Item>(); items.Add(new ...
3
votes
3answers
475 views

Should I try it straight or should I first check if it can be done?

I have a set of items, and each item in the set must be unique. Item are composed from multiple properties and each property of each item can be changed. But after each change every item in the set ...
0
votes
0answers
38 views

Switch Configuration of Several .Net Programs for Several Sections in a Simple Way

We build a highly configurable .Net Client/Server application. (Client is C#/WPF, Server is C#/WebService) There is a single code base, but each customer has its own 'profile'. The profile ...
2
votes
1answer
226 views

How to solve this problem of duplicate code with a design pattern [duplicate]

This is what I am doing, Creating a new Pdf document using Aspose Pdf Adding few different types pages you know introduction page, table of content pages etc... Adding some further documents to it ...
0
votes
1answer
153 views

Interface or boolean?

I have a CustomObject class which has the abilities like being Clickable, KeyPressable and Movable. I created interfaces: IClickable, IKeyPressable and IMovable and make different CustomObject classes ...
14
votes
2answers
797 views

Is there some sort of systematic strategy for designing and implementing GUIs?

I am using Visual Studio to create a GUI application in C#. The Toolbox serves as a nifty component palette that allows me to easily drag and drop buttons and other elements (for clarity I'll say ...
0
votes
1answer
121 views

What is the correct way to bind few classes with similar functionality?

I want to do this in the right way to learn I have a few classes which have only one method. For example: public class RedColorText { public void AddRedColorText(string text) { ...
0
votes
2answers
49 views

Releasing updates to Windows Services and Websites from build

I've got an solution which consists of Windows Services and websites. When updating the applications currently, the following steps are undertaken Build of solution Post build tasks copy the DLLs ...
12
votes
5answers
999 views

This way I'm writing this code is testable, but is there something wrong with it I'm missing?

I have an interface called IContext. For the purposes of this it doesn't really matter what's it does except the following: T GetService<T>(); What this method does is look at the current DI ...
0
votes
4answers
229 views

Identifying user of a webapp

For a small webapp I want to be able to identify a user. The issue is, if the user cheats in some manner, I want to be able to forbid him the usage of my application. I already have done extensive ...
1
vote
1answer
116 views

Optional referenced-type paremeter

I know in C#, by default, referenced type variables are passed by reference to a method then the changes reflect on the object outside the method. I have a function which sometimes I just need its ...
1
vote
1answer
197 views

How to write unit tests for a piece of code that has a data context?

I am new to unit testing and using Microsoft's unit testing library for following piece of code. When I execute the code normally it executes fine, however when I run unit test written for this code I ...
3
votes
1answer
102 views

Unit testing a template class after refactoring

I am cleaning up my code by way of removing duplicates, and found two classes that were almost identical, out of 55 lines, only a single predicate in an if statement differed between them. Both ...
5
votes
4answers
168 views

Using struct to enforce validation of built-in type

Commonly domain objects have properties which can be represented by a built-in type but whose valid values are a subset of the values which may be represented by that type. In these cases, the value ...
6
votes
4answers
228 views

Are noncontiguous arrays performant?

In C#, when a user creates an List<byte> and adds bytes to it, there is a chance it runs out of space and needs to allocate more space. It allocates double (or some other multiplier) the size of ...