Tagged Questions
C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform
0
votes
1answer
24 views
How to create good positive and negative images for opencv to distinguish smiling from not smiling?
My goal is to create an opencv haar classifier xml that distinguishes between me smiling and not smiling.
I created images, cut them, showing me smiling and as negatives not smiling. About 5000 ...
-2
votes
0answers
22 views
(CQRS) with ASP.NET MVC5
I have a project and want to implement that,using ASP.NET MVC5 and N-Layer architectural pattern.I become interest to use Command Query Responsibility Segregation (CQRS) in my project.I am new to CQRS ...
-1
votes
1answer
80 views
How to selecting Teams with Minimum Difference between Knowledge Levels
For the below challenge from a programming site, I am bit confused.
Problem Statement:
A Professor of Physics gave projects to the students of his class. The students have to form a team of two for ...
0
votes
1answer
98 views
Most efficient LINQ result for Contains() query
I currently use the following:
var result = list.Union(otherList).SelectMany(l => l.children).ToList()
foreach(var child in lotsOfChildren){
something = result.Contains(child)
}
I only use ...
-2
votes
0answers
20 views
How to fill the linear gradient brush region from the original region? [on hold]
I’m using LinearGradient brush to fill the region and I created the linearGradient brush using starting and ending points, Color.
Rectangle linearGradientregion= new Rectangl(20,-50,30,30);
...
-4
votes
0answers
47 views
how to analyze some thing by OOP concept [on hold]
I have been studying OOP for 1 month. However I still don't understand the main concepts of it.
Would you please show me an example that demonstrates the core OOP concepts?
I 'm Vietnamese , so my ...
-3
votes
0answers
53 views
What is the best architectural approach for my asp.net mvc website? [on hold]
I want to create a product as website,Andriod app,IOS app and Windows app. To create website I want to develop with asp.net mvc,angular js and database in Neo4j(graph database). Below are the ...
1
vote
0answers
122 views
How to Use Python as a “Macro” runner for a C# Application
I am working on an application that the user may wish to automate some features of (but we don't know what at the moment) I would like to provide them some kind of scripting interface so they can play ...
1
vote
1answer
109 views
Decorater pattern or strategy pattern
I'm constructing a c# serverside application and I'm trying to do this in a way it can easily be maintained aswell as extended if needed.
So what we have is 4 different requests that need to be done ...
-2
votes
1answer
61 views
Factory for abstract class
I have an abstract class MyAbstractClass.
I also have lots of implementations of that class, and I want to create a factory for these implementations.
Need to end up with usage like that: ...
3
votes
2answers
622 views
How can I avoid these nested repetitive ifs?
I'm trying to implement a web interface for a user database. Hosts can create guests for their courses, the guests can get deleted after the course has ended but have to remain in the database for a ...
0
votes
1answer
106 views
Where should the following business logic be written?
I have a C# console application. This application has many different projects/C# class files, each of them dedicated to parsing a certain kind of XML and creating an object, called 'Response'. Now, ...
-3
votes
0answers
20 views
Form that was specified to be the MdiParent for this form is not an MdiContainer [closed]
My system used be accessible until i add a new form.
Accessible :
Login lg = new Login();
lg.MdiParent = this;
lg.Focus();
lg.Show();
Then when i added a new ...
0
votes
5answers
264 views
Interview Question - Adding Method to interface that has been implemented by thousands of class [closed]
There is scenario where I have Interface X, which has been implemented with my thousands of classes. Now I want to add new method in that Interface X. So how to make the changes in minimal way to ...
-1
votes
0answers
34 views
Using Process.Start to capture console output [migrated]
unfortunately i'm new in C# and this should be a stupid question but i need it, hope someone should help..
Based on this article: ...
2
votes
2answers
204 views
+50
Can I update an attached object using a detached but equal object?
I retrieve movie data from an external API. In a first phase I will scrape each movie and insert it into my own database. In a second phase I will periodically update my database by using the API's ...
0
votes
1answer
86 views
When and how to apply application settings in .Net
I know that I can access application settings in .Net using Properties.Settings.Default.aSetting.
What is the best way to apply them:
To directly read them in the function which relies on
them. ...
6
votes
1answer
367 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 ...
0
votes
2answers
86 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
45 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
946 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 ...
17
votes
7answers
4k 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 ...
-4
votes
1answer
139 views
Are there any languages that don't need to be compiled? when dealing with c# [closed]
Are there any languages that don't need to be compiled? when talking about c# in programming
-3
votes
0answers
115 views
Filtering out images that are in the golden ratio [on hold]
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 ...
5
votes
2answers
154 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 ...
3
votes
2answers
110 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 ...
3
votes
2answers
167 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
112 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 ...
1
vote
1answer
42 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 ...
0
votes
1answer
40 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 ...
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.
...
-4
votes
0answers
26 views
Sync Microsoft dynamics(nav) with remote mysql [closed]
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 ...
0
votes
2answers
91 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
1answer
105 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 ...
-1
votes
0answers
36 views
Visiting specific cells of an array [closed]
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
52 views
Lock object in base class: private or protected? [closed]
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 ...
1
vote
1answer
104 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 ...
1
vote
4answers
220 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 ...
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
{
...
34
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, ...
2
votes
1answer
198 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
47 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 ...
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 ...
0
votes
2answers
91 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
vote
2answers
79 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
159 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 ...
3
votes
1answer
137 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
1answer
52 views
Technique to synchronize error codes in a same-project-API
In the project I am working right now, we have some python and some C# code. At some point, I call from python a subprocess which starts a C# executable. This C# code returns an error code, which has ...
2
votes
5answers
260 views
Is it bad or good to wrap mutable objects in immutable containers?
If I have parts of code that need to mutate the underlying data structure but then others that consume, not mutate the structure, is it good practice to create a wrapper which does not expose mutation ...
1
vote
1answer
121 views
Does merely parameterizing a dependency meet the requirements for Inversion of Control?
When I find a concrete dependency inside an extension method, I have been attempting to remove the (concrete) dependency by parameterising it like so
// original implementation
public static ...