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

4
votes
3answers
384 views

readability vs shorter code in returning from function

In something as simple as int sq(int x) { int y = x*x; return y; } versus int sq(int x) { return (x*x); } the former function requires an extra IL step. EDIT: IL code from the first example, ...
-3
votes
1answer
39 views

ERP system with C#? [on hold]

I'm in intermediate level in C#, and I want to specialize in ERP field. what qualifications required in the programmer to be qualified as an ERP developer. at the moment my knowledge about ERP is not ...
-4
votes
1answer
25 views

Cross platform app (Windows, Web, Android & iOS), preferably with VS & C# as of end 2014

I recently (end of 2014) read about new technologies from Microsoft about developing cross platform apps (Apache-Cordova and more). I'm pretty unclear with what's going on and what are the options. ...
0
votes
1answer
73 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
1answer
175 views

Organizing Business and Presentation entities

Background I am developing a WPF project. This is the basic structure: User Interface (WPF Project); Interfaces (class library, contains all the interfaces and the entities used by the ...
48
votes
9answers
36k views

Why use partial classes?

In my understanding, the partial keyword does nothing but allow a class to be split between several source files. Is there any reason to do this other than for code organization? I've seen it used for ...
0
votes
2answers
91 views

Interface inherits from interface without specifying new member

Is it some kind of bad design to have something like this: public interface IFooStream { long Length { get; } long Position {get; set;} //... } public interface ...
0
votes
1answer
52 views

Tracing and Logging per item instead of per application

I'm building a service in .NET that process "things" in the background and I'd like to trace the execution of these things per item, not per application. Most logging frameworks (I'm familiar with ...
4
votes
2answers
296 views

What are the valid uses of static classes?

I noticed that nearly every time I see programmers using static classes in object oriented languages such as C#, they are doing it wrong. The major problems are obviously the global state and the ...
1
vote
1answer
65 views

How to store/deal with data available to other classes

I'm writing a CAD program. Let's say I have in input class, this class reads various data from a text file and creates lots of lists/dictionaries and .... These data need to be accessed by other ...
0
votes
2answers
191 views

Is using multiple static classes with maximum one public method is a good idea

I'm writing a structural detailing (CAD) software for concrete buildings in C#. I have defined like hundreds of static classes each with one public method and if needed some private methods. Each one ...
3
votes
3answers
298 views

Method waits for user action

I have a structural problem for an application I'm working on. In the interest of full disclosure, it is for a university assignment so I'm not looking for you to code me an answer, just help me ...
8
votes
2answers
898 views

Ideal data structure/techniques for storing generic scheduler data in C#

I am trying to implement a generic scheduler object in C# 4 which will output a table in HTML. Basic aim is to show some object along with various attributes, and whether it was doing something in a ...
3
votes
2answers
2k views

looking for a short explanation of fuzzy logic

I got the idea that basics of fuzzy logic is not that hard to grasp. And I got the feeling that someone might explain it to me in like 30 minutes. I understand neural networks and am able to re-create ...
14
votes
9answers
2k views

Is it good practice to inherit from generic types?

Is it better to use List<string> in type annotations or StringList where StringList class StringList : List<String> { /* no further code!*/ } I ran into several of these in Irony.
6
votes
2answers
597 views
+100

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 ...
3
votes
2answers
243 views

C# static practices coming from dynamic background

I have been dappling in C# after coming from several years in PHP. I don't find the language particularly difficult, although there are considerably more constructs for me to get used to. My question ...
0
votes
0answers
38 views

adding model specific CRUD operation web api endpoints

Are there are any major design flaws / smells in creating a web api as described below The models I have public class CourseModel { public String Name {get; set;} public ...
0
votes
0answers
26 views

Add Claims/Roles on Resource server (From Token Authorization server)

I've coded up a Web API 2 Authorization server that I am using to get a token for a given user. I can use that token to send requests to my Resource servers that use [Authorize] attribute in the ...
-1
votes
1answer
30 views

How to use MeshGrid method in Accord.Math Matrix Class? [on hold]

I am using the Accord.Math Namespace for Visual Studio in c#. I am trying to use the method MeshGrid<> under the Matrix class for the Accord.Math namespace. However, I am unsure how to implement ...
-2
votes
0answers
35 views

Show BBCode in WPF [closed]

I'm working on a C# WPF project where I want to store pages in bbcode (for example "[b]Bold[/b] [link]Other site[/link] etc.) and show it later. Now I'm hanging at this point: How do I show this with ...
3
votes
3answers
631 views

Why using string[] args in all main methods?

I'm a beginner in learning programming. I ask about using the string array in main method as a parameter. Why not writing the Main() method without the string array? What is the point of having this ...
-2
votes
0answers
16 views

Change Windows Lock Screen background image in C# [migrated]

Is there a way to change the lock screen image like the wall paper in c# using pinvoke. [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern Int32 SystemParametersInfo(UInt32 ...
10
votes
8answers
3k views

Data structure for accessing units of measure

TL;DR - I'm trying to design an optimal data structure to define units within a unit of measure. A Unit of measure is essentially a value (or quantity) associated with a unit. SI Units have seven ...
2
votes
1answer
1k views

const vs. readonly for a singleton

I have a singleton that anchors together some different data structures. Part of what I expose through that singleton are some lists and other objects, which represent the necessary keys or columns ...
1
vote
1answer
55 views

OK to make a method generic just to pass in a System.Type?

Sometimes I have a function that takes a System.Type parameter, like: public void Foo(Type type) { // do something with "type" ... } This must be called like this: Foo(typeof(MyType)); I ...
-3
votes
0answers
48 views

automatically check textbox length c# [closed]

For a project at school, I use an RFID reader to read a code. The RFID reader is presented to my pc as an keyboard. What the program should do is scan a code, get some data from the database and move ...
1
vote
2answers
197 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 ...
5
votes
2answers
231 views

Should I use events or abstract methods?

Lets say I create an abstract class that manages some network functionality for me. I want to be able to be notified when something changes. For example: OnConnect or OnDisconnect. Should I create ...
1
vote
0answers
71 views

How does one enforce the implementation of a static method? [duplicate]

Of course the answer to the question above is, "you can't". But I didn't have a better way of describing what I'm looking for. If I did, I wouldn't be asking this question. My problem stems from a C# ...
4
votes
1answer
235 views

Implicit Conversion Operators for Value Types in C#

I’ve come across this blog article: Implicit Conversion Operators are Bad. The article discourages the use of implicit conversion with reference types. The article describes problems caused by ...
0
votes
2answers
597 views

Thoughts and Best Practices on Static Classes and Members [closed]

I am very curious as to thoughts and industry best practices regarding static members, or entire static classes. Are there any downsides to this, or does it participate in any anti-patterns? I see ...
7
votes
3answers
747 views

When to use .ToString() when concatenating a string in C#?

int a = 1; int b = 2; int sum = a + b; string expression = "Expression: " + a + " + " + b + " = " + sum; Console.WriteLine(expression); //displays Expression 1 + 2 = 3 Should I use: string ...
0
votes
2answers
180 views

How are the tiles in WORDAMENT organized?

I'm trying to create a word game, just like WORDAMENT, in my spare time. In order to present a new round, I need to create a board with 16 letters organized in a 4*4 grid. Currently, I'm generating ...
1
vote
2answers
528 views

Tree View Children condition indicator on topmost un-expanded parent

I am using a tree view in c# and i am creating custom icons for the nodes. Let say this is my hierarchy with a node that satisfies a certain condition: Root1 |_Ax |_Bx1 |_Bx2 |_Cx1 ...
17
votes
14answers
3k views

Is there ever a reason to use an array when lists are available? [closed]

It seems like List<T> in C# can do everything an array can do and more, and seems also just as efficient in memory and performance as an array. So why would I ever want to use an array? I'm ...
2
votes
1answer
209 views

C# OOP Class Usage [duplicate]

I am just being picky and really wanted some of my code to look, feel, and be used a specific way but am not sure if its possible. I have a class I created that can be used like this ...
3
votes
3answers
231 views

ASP.NET MVC should I reference the DAL from the UI?

I am developing an ASP.NET MVC application, and I have three projects: UI (with the system.web.mvc reference, BL and DAL references) BL (business facade and business objects) DAL (contains my ...
0
votes
2answers
563 views

How I could update a DB table using a POCO class bound in a DataGridView

I try to explain better using an example: I create the class Product with attibutes like that: private string _ProductCode = ""; [DisplayName("ProductCode")] public String ProductCode { get { ...
22
votes
6answers
10k views

Explicitly defining variable data types vs. using the keyword 'var'?

In C#, am I encouraged to use the all-purpose var keyword for every variable declaration? If yes, do I have to mention those special characters for literal values within the variable declaration like ...
-1
votes
0answers
23 views

Best way to aproach creating an MRP [closed]

Ive been ask if I could create an MRP (Material requirements planning) program, from what I have read its seems like a complex program manager, I've been working on it for a couple of days now, and ...
-5
votes
0answers
71 views

how to scan a document using client side scanner in asp.net Web application [closed]

I'm using Asp.net web application (C# language). Want to Scan a document from clicking a button in web application (i.e. Browser). I already tried Twain tools But I need any other way to scan a image ...
1
vote
1answer
156 views

Is it OK for an interface to only communicate half of how something should work?

I have a service where certain other services can report their status to. By status I don't mean whether they are running or not, but whether they have received data. The point is that other services ...
0
votes
4answers
112 views

What is the preferred way to hold a file over multiple requests in MVC

I am building a wizard and the first step of this wizard is to let the user select a file. In the following steps I need this file to display some data from it and as a final step I have to import ...
0
votes
3answers
404 views

Gathering IP address and workstation information; does it belong in a state class?

I'm writing an enterprisey utility that collects exception information and writes to the Windows Event Log, sends an email, etc. This utility class will be used by all applications in the corporation: ...
5
votes
2answers
410 views

Trying to identify IClass, Class, ClassImpl pattern

I've been seeing a lot of code recently that looks like this: public interface IFoo { int Bar(); } public static class Foo { public static IFoo Create() { return new FooImpl(); } private ...
3
votes
2answers
205 views

Using reflection vs creating a new class

I and a friend are having an argument on what is the better technique to use in the following scenario: An application we need to test has a number of components (lets call them Eggs); each component ...
0
votes
2answers
90 views

Track a series of choices with a single number

I want to track a series of scored questions in a single number (the total score). Is that possible? and how? For example, I have 30 questions with either 3 or 2 choices. For any given question, the ...
0
votes
1answer
185 views

Using Statement lambda in exception handling

Following is a code snippet from MVP Win Forms application and this explanation would be helpful when answering the questions. My DAL doesn't handle exceptions and it will be propagated up to the ...
30
votes
10answers
10k views

Is catching general exceptions really a bad thing?

I typically agree with most code analysis warnings, and I try to adhere to them. However, I'm having a harder time with this one: CA1031: Do not catch general exception types I understand the ...