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
3answers
287 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
885 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
557 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 ...
0
votes
1answer
71 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 ...
3
votes
2answers
233 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
29 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
25 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 ...
0
votes
1answer
23 views

How to use MeshGrid method in Accord.Math Matrix Class?

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 [on hold]

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
626 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
50 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
47 views

automatically check textbox length c# [on hold]

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
195 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
226 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
586 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
725 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
178 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
523 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
205 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
221 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
560 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
21 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
65 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
155 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
110 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 ...
-4
votes
0answers
112 views

Java and C# is confusing me a lot. Any explanation on the difference between the two? [closed]

I'm new to programming and I'm still confused as to what is the difference between Java and C# and what are the benefits of both and which is better for programming.
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
409 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 ...
-2
votes
0answers
34 views

Manage browsers add-ons programmatically [closed]

I have a requirement to enable and disable installed browser add-ons using C#. By using below code we can get installed browsers list RegistryKey browserKeys = ...
-2
votes
0answers
22 views

vb.net lock error - from2 models (buttons, labels etc) copied to form1 [closed]

my project was working fine until some how form2 models (buttons, labels, etc) copied to form1 and I am unable to delete them or move. Below is an image of what its giving me therefore unable to ...
3
votes
2answers
204 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 ...
9
votes
5answers
2k views

Which are the cases when 'uint' and 'short' datatypes are a better fit than the standard int(32)?

I understand the differences in capacity and values they can represent but it seems as though people always use Int32 regardless of whether it is appropriate. No one ever seems to use the unsigned ...
1
vote
3answers
351 views

Which one of these would be the better way to implement object copying in c#?

I would like to be able to copy an object and only change a few values. I have come up with two different ways to do this. // OPTION A - create a copy constructor and use property // ...
13
votes
9answers
5k views

Should you make private properties?

private string mWhatever; private string Whatever { get { return this.mWhatever; } set { this.mWhatever = value; } } I've seen some people who make ...
1
vote
1answer
186 views

Clarification about Event Producer in StreamInsight

I need a small clarification about StreamInsight, I know by doc's that StreamInsight can handle multiple concurrent Events. But will the event producer be a separate function, for ex: I need to watch ...
3
votes
5answers
710 views

Creating a sort of 'in-language compiler'

I'm not saying I want to create a whole new compiler that's completely independent. I'm using C# Windows Forms and I want users to be able to write filtering syntax in a textbox withing my managed ...
0
votes
1answer
62 views

Is automatic conversion to collection types from non-collection variable a good idea? [closed]

Consider public void Do(string[] aBunchOfStrings) { } or public void Do(IReadOnlyList<string> aBunchOfStrings) { } Would it be a bad idea to allow the function call Do("woei"); resolve ...
-1
votes
4answers
90 views

Adding non distinct elements to a dictionary

Suggestions on a good pattern to follow to add elements to a dictionary where you want to add an element if it does not exist, else do nothing The 2 approaches I can think of are ...