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

-3
votes
0answers
20 views

How would one go about writing code in C# that interfaces with STMicroelectronincs (CR95HF) NFC Reader

For a project from school I want to do something with NFC. I received an NFC reader from a teacher and said that I could borrow it. At this moment I have only experience with C#. How would one go ...
-4
votes
0answers
22 views

WordPad n Notepad is not opening with SQL Server 2012 and VS 2012 in Windows 7 .pls help me [on hold]

I'm using Sql Server Management 2012 and Visual Studio 2012 with windows 7. whenever i try to open MS office Word pad i get a message like This :"Windows Can't access the specified device,path, or ...
0
votes
2answers
97 views

if a c# interface contain only getter and setter definition, is it a code smell?

A project that I am working on has the following code for interface example: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test { public ...
0
votes
0answers
29 views

Totalising and condensing data values from multiple arrays into a single array

My fledgling programming skills have hit a wall. I could get this working, but the code stinks and I'm convinced there must be a more efficient way I just don't know it yet. I have a web service ...
0
votes
3answers
127 views

Using action array vs Switch Case

I have an occasion of code in which I will draw a different set of buttons in a screen (depending on the number of the buttons). One thought (and my current implementation) is to use an action array ...
27
votes
9answers
4k views

Should I accept empty collections in my methods that iterate over them?

I have a method where all logic is performed inside a foreach loop that iterates over the method's parameter: public IEnumerable<TransformedNode> TransformNodes(IEnumerable<Node> nodes) { ...
-2
votes
0answers
20 views

Using Reflection to load dependent dll in Assembly [on hold]

I am using reflection to load dll "A" and display collection of values using c# project. Assembly appAssembly = null; appAssembly = Assembly.LoadFrom("c:\App\A.dll"); But there are empty values ...
0
votes
2answers
154 views

Bad Practice using Auto Generated Classes for Data Access

I've seen this before but haven't found concrete reasons. When you add Entities to your EF model, EF auto generates classes for these entities. In terms of DataAccess, why is it preferred to not ...
0
votes
1answer
77 views

Async properties in interfaces to cater for the possibility of expensive first-time evaluation: Is this a good idea?

First of all, sorry if this post is too long. I'll start with the… Short version: Is it generally advisable or a good idea to design an interface property as asynchronous simply because we cannot be ...
1
vote
2answers
124 views

How to write a custom EventHandler class

When I started using Java, I created a custom Event class to mimic C#'s implementation of Events. Since then, I've added some other features, like event listener priorities, and cascading events were ...
-5
votes
0answers
104 views

Why should I ever implement structs? [duplicate]

Structs are value types so they're more expensive to handle. Classes are more capable that Structs. What are the reasons to ever choose to use a Struct in C#?
-1
votes
0answers
16 views

removing padding from column transposition c# [closed]

I have done a column transposition (see first part below) and i'm working with bytes to transposition an image (for encryption purposes) because I am using a 2D array I have had to use padding to fill ...
0
votes
1answer
154 views

Speech Recognition in the .NET framework is not efficient [closed]

I want to create a Virtual Keyboard that can catch whatever key you 'speak' and send the keystroke to the active application. The Virtual Keyboard part and linking it to Speech Recognition will be ...
12
votes
7answers
2k views

Name/Fix for Production Code Whose Sole Purpose is to Facilitate Testing? [duplicate]

The linked "duplicate" question is an iffy match at best, because it's asking is pattern X OK (YES/NO) and I'm clearly already in the NO camp, and subsequently asking what is pattern X called ...
-6
votes
0answers
61 views

what is good for performance in for and for each loop of c# [closed]

what is good for performance in for and for each loop of c#.
2
votes
1answer
124 views

In what way are union types better for correctness than a common interface?

I've just recently started familiarising myself with functional programming, mostly via F#, and there's one particular functional idiom that I'm not fully understanding the benefits of. I've seen it ...
0
votes
1answer
54 views

Is there a standard to imitating an async filestream

Im trying to replace an async filestream method, which is reading data from a Hid Device and feeding it to the UI. Ive considered writing the output into a log and then importing that log again, but ...
0
votes
3answers
211 views

Force Derived Class to Implement Static Method C#

So the situation is like, I have few classes, all of which have a standard CRUD methods but static. I want to create a base class which will be inherited so that it can force to implement this CRUD ...
0
votes
1answer
65 views

Inverse property naming (ORM scenario) [closed]

I have a class that represents a process. In this process there are inputs boxes and output boxes. public class Process { public long ProcessId { get; set; } public virtual List<Box> ...
0
votes
0answers
39 views

How can I control the naming used when mapping foreign keys where there are more than one list of same class contained [migrated]

public class Person { [Key] public int ID { get; private set; } [Required] [StringLength(100)] public string PersonName { get; set; } } Creates "People" table ID | PersonName | ...
-1
votes
0answers
17 views

Get the Foreign Key table data along with Requested data [migrated]

I have two tables where one table Location References(using Foreign Key relation) to another Table. I am Using Dapper i want to Get the Location Details as well for the Given Customer Table. Like the ...
0
votes
1answer
68 views

Which transaction manager will be used in WCF?

I am going through the transactions exist in WCF service but seeking some more clarification on this. I am not sure about which transaction manager WCF will use for following scenarios: If the WCF ...
1
vote
1answer
66 views

Setting fields of a base class when using the constructor is not an option

I am refactoring a base class, implementations of which are plug-ins, loaded at runtime by another class using reflection. The class I am refactoring uses a user ID of the form domain\user. I need ...
0
votes
1answer
44 views

DAL / Model / Application-Design Question for a MVC Application

I have a device that stores raw binary log data as a BLOB in a MySQL DB. That process is a blackbox to me (closed source) which I cannot change. I know, however, how to decode that BLOB and transform ...
-1
votes
0answers
11 views

How do I save a Winforms panel's drawing content to a file? [migrated]

I made a paint program, and the drawing content (from System.Drawing) is drawn on the panel. I attempted this method to do a simple save for now, and I only get a blank image. My bitmap has its ...
1
vote
0answers
42 views

Does using membership provider in the model of a MVC project mean the model knows it is part of a website?

My basic design is that the model is in a separate project from my website, and the project never references the website. That tends to enforce the model being agnostic of how it is being used. But ...
2
votes
3answers
52 views

Pre-processor usage to separate logic to different versions of product

In the .NET code base of a product, there are #if pre-processor statements to define whether certain functionality should be available. Like so: shared logic #if version1 some logic #endif #if ...
0
votes
0answers
44 views

Accessing a stateful managed object from native code via a static variable [migrated]

I need to create a native C++ DLL that will be an interface/wrapper over a C# class. I've never done anything like this before, but my design is basically the same as this. In other words: I have a ...
0
votes
1answer
69 views

What possible things to log in mvc webapp [closed]

I'm about to learn to handle logging in my c# asp.net mvc app and are going to store my log in a noSQL-db. How to handle the logging is done. The thing is I'm having a hard time to figure out possible ...
2
votes
1answer
267 views

2 questions about TDD

I'm just starting to get to grips with TDD, and I have 2 quick questions; I'm assuming that if I were writing software for a software company, that TDD would work alongside the software design? i.e ...
0
votes
2answers
92 views

Mocking the context of application

We have a context of the application which is a static class named Holder containing several static properties initialized by objects that are used throughout the application. All over the unit tests ...
-1
votes
0answers
37 views

How to search for requested text backwards? [migrated]

Go to Notepad. Type in "This is a test this is a test this is a test". Put the caret to the very end of the text. Go to Edit -> Find -> Type "is" -> Set the direction to 'Up'. Each type clicking ...
1
vote
0answers
129 views

C# structure needed for dynamic behaviour

I am using Unity to build a visualisation of a serious game. I am using the C# programming language. My problem is that I receive data from a JSON and I parse it and I end up with a list of different ...
12
votes
2answers
885 views

How to calculate figure rotation efficiently?

I have a Figure represented through a matrix of bytes (bitmap-like matrix). Example Figure is shown on the Picture 1. The goal is to find the best rotation angle of some given Figure. When Figure ...
0
votes
0answers
34 views

Decreasing MongoDB Load

I have some stream workers. They are listening to twitter stream and save into mongodb. I need to aggregate saved tweets for intermediate analyze result. I have analyzer workers. They are periodically ...
1
vote
1answer
79 views

Controller / Service - Should a service save changes to the database

I have an action on my controller called DeleteLine. This removes a line from the users basket. My controller action looks like this: [HttpGet] public ActionResult DeleteLine(int orderId, int ...
-3
votes
0answers
25 views

Visual Studio Team Test: How to unit test “?” operator with only Asserts() and not using any tool [migrated]

I need to write some unit test cases to test my code in C# Visual Studio Team Test framework. Below is the method I want to test: public static Association CreateAssociationFromXrm(Xrm.pv_association ...
1
vote
1answer
169 views

How to find duplicate strings

I allow my user to create profiles, meaning they potentially could create some with duplicate names. This can be problematic so I want to prevent them from doing so. I coded up this first pass ...
-2
votes
0answers
46 views

Adding a link label for a list of features [migrated]

I have a class that contains a list of features and I would like to add a link label for each item in that list. When doing this, I am not able to display all of the features, only the first feature. ...
0
votes
0answers
43 views

Creating a user-customizable web api

Technologies: Javascript for $http call, ASP.NET Web API, MSSQL for data retrieval Web API will return array of widget objects with following properties: WidgetId, WidgetAttribute1 Bool, ...
0
votes
1answer
138 views

Good design pattern for linq to sql

I currently have a linq to sql project that was used for one project and not much work was put into it, only the generated context and entities were used. Since then the project has started to become ...
0
votes
0answers
13 views

Returning the contents of a byte Array Function C# [migrated]

I'm trying to get better at coding and more specifically, getting in to the habit of using functions to do things rather than have everything in "Main". I can't seem to find an answer which I can get ...
3
votes
1answer
142 views

Web Forms and MVC in the same web project

I'm working in a large legacy project which was build with ASP.NET Web Forms and the idea to add in the MVC libraries to the same project has been tossed around. I know that this is possible (there ...
1
vote
4answers
234 views

Order by different Enum property each row

So I have a list of DefaultSearchModal items that have an enum called TypeSearch in every list item. I would like to order the list to have a different enum property each row. So if you have an ...
0
votes
1answer
81 views

More appropriate to validate a dependency filter parameter by mock+stub or by expression compile?

My lead is enforcing TDD on our project. He says he's following Uncle Bob (Robert Martin) and SOLID principles. One of the rules he's reinforcing is what I call "the single cog rule"--there should be ...
4
votes
1answer
209 views

Does laziness yield more race conditions?

I recently ran into a race condition while accessing a configuration setting. After examining what I could of the code, I came to the conclusion that the Configuration class' laziness1 was the source ...
1
vote
1answer
53 views

Why does a custom action filter need to inherit from both ActionFilterAttribute and IActionFilter?

I m first time creating a custom action filter and following this link http://www.asp.net/mvc/overview/older-versions/hands-on-labs/aspnet-mvc-4-custom-action-filters They are saying to Extend ...
0
votes
2answers
121 views

how to carry a specific number of significant figures while computing? [closed]

How to carry more or less than six significant figures (4 , 5 , 7.. ) in the computation while running a program ? i'm writing a program to solve a system of linear equations /using Gauss elimination ...
0
votes
0answers
3 views

pass data between two forms in c# [migrated]

I have a form with a button, when the button is clicked, the [public int m = 0] changes 1. I have another form [form2], when I make a new class from form1 to get m value, it passes 0 and I don't know ...
2
votes
1answer
226 views

My first SOLID re-factoring

I am trying to make use of SOLID principles for the first time. I am re-factoring a File class that stores file information and makes file operations available. This class is then inherited to ...