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

-7
votes
1answer
34 views

C# program to display 12345 on screen [on hold]

How this code works plz tell me step by step For ( into i=1;i<=5;i++) { for (int j=1;j<=1;j++) { console.write(" "); console.write("i"); } console.write ("\n"); console.writeline ("display ...
0
votes
1answer
188 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 ...
4
votes
4answers
192 views

What kind of user info is ok to be stored as plain text in SQL Database?

I'm practicing around building e-commerce asp.net applications that allows for users to register to the site and their user credentials are stored in a MySQL database. In my sample project the ...
1
vote
2answers
677 views

Database Context and Singleton injection with IoC

All of the below relates to a ASP.NET c# app. I have a Singleton Settings MemoryCache that reads values from database on first access and caches these, then invalidates them using SQL Service Broker ...
0
votes
1answer
39 views

Clients connect to WCF or SQL Server

I was wondering what is the prefered way of accessing data from a server in a client application. The data will be stored on the server in an SQL database and I have previously used the following 2 ...
-4
votes
0answers
28 views

Problem in C# Datagridview form application [on hold]

In Datagridview, if the Column is of type combobox, then we have to click on the value or select by keyboard even if the top most item is selected. Otherwise the value is not selected. Which property ...
0
votes
3answers
328 views

Manage ClickOnce releases for different parties

I'm struggling with release management of a piece of software. First some general information: It is a ClickOnce application I follow the release often practice There are about 30 parties served ...
-3
votes
0answers
29 views

C# - Use too many buttons as 1 variable [migrated]

I have a fairly simple question. I want to change the background color of 15 buttons, but is is very cumbersome to write button1.backgroundColor = Color.black button2.backgroundColor = Color.black . ...
1
vote
2answers
579 views

Data transfer between “main” site and secured virtual subsite

I am currently working on a C# ASP.Net 3.5 website I wrote some years ago which consists of a "main" public site, and a sub-site which is our customer management application, using forms-based ...
14
votes
8answers
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.
0
votes
0answers
35 views

Silverlight-based “area of influence” algorithm

I am in the process of developing a tool for a game called MechWarrior: Online which defines a map of an area of space called the Inner Sphere. Essentially, this map is a set of points (planets) on a ...
1
vote
1answer
173 views

why “new” keyword is not contextual keyword?

Based on: C# Keywords Keywords are predefined, reserved identifiers that have special meanings to the compiler. and Based on: Contextual Keywords A contextual keyword is used to provide a ...
1
vote
1answer
185 views

In C#, performance wise, an object's size does matter when you access one of its members through a reference?

It may be a stupid question but in C#, performance wise, an object's size or complexity does matter when you access one of its members through a reference? Or only that specific member is all that ...
4
votes
4answers
524 views

readability vs shorter code in returning from function [closed]

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, ...
-4
votes
1answer
68 views

ERP system with C#? [closed]

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 ...
0
votes
1answer
74 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
177 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 ...
49
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
92 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
61 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
377 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
71 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 ...
1
vote
2answers
209 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
303 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
901 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 ...
6
votes
2answers
622 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 ...
3
votes
2answers
256 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
39 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
28 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? [closed]

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
3answers
638 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 ...
1
vote
2answers
198 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
235 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
240 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 ...
1
vote
2answers
620 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
761 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
185 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
532 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
210 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
248 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
565 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
vote
1answer
158 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 ...