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

0
votes
1answer
28 views

How to go about saving a Snippet / Block of Code - C#

I am currently learning C#, I am pretty proficient in Java. A project I have been working on for a while is basically an application that lets you input code "Snippets" or blocks of frequently used ...
0
votes
0answers
25 views

Creating New Wrapper Objects and Extension Classes and Keeping it Organized

Here's my situation: I'm programming an embedded device with a very simple, but customizable LED array display. It's 10 RGB LEDs linearly setup. The LEDs will be used to display many different ...
2
votes
1answer
74 views

Accessing a private array when I have an extension method

I'm trying to make a number of data classes for my C#/XNA game, which would essentially be a wrapper around T[,]: public interface IGrid<T> where T : struct { Point Size { get; } T ...
0
votes
1answer
49 views

Advise on loose coupling between user controls

I have 5 user controls on the page and each control implements it's own interface that contains properties and events. In order to enable communication between user controls, I am creating a property ...
6
votes
8answers
831 views

Would a “downcast if block” be a reasonable language feature?

Consider the following "if cast": class A { public void f1() { ... } } class B : A { public void f2() { ... } } A a = foo(); // might return A or B if ( a is B ) { // Inside block, ...
2
votes
2answers
179 views

Is there a point in using closures for non-fully functional programming languages? [duplicate]

Maybe I don't understand closures fully but take for example C#, why would I use closures when I can use classes? Am I missing something? Note that I read this one already but my question is specific ...
0
votes
3answers
62 views

Relative encapsulation design

Let's say I am doing a 2D application with the following design: There is the Level object that manages the world, and there are world objects which are entities inside the Level object. A world ...
0
votes
3answers
241 views

C# - Typical instantiation of new object - is there a way to avoid repetitious syntax?

When learning C# (and OO concepts more generally at the same time) something I found very distracting is exemplified by the following line: ExampleClass exampleObject = new ExampleClass(); It's the ...
0
votes
0answers
42 views

How to design socks proxy server (OOP)

I'm working on a socks server application written in C#. But I don't really know how to design this in a nice way. I got this for Socks V4 and V4A: I'm not sure if it clears things up, but I think ...
1
vote
0answers
26 views

how to process document state transition?

Imagine there is an application (ASP.NET MVC) that processes some documents. The document must be revised several times by different group of users. state/role rules: simple user can only publish ...
0
votes
1answer
163 views

How to make C# methods work like javascript functions?

I'll keep it simple, I want to make C#'s methods work like javascript's functions. Mainly so I can convert this - function makeVariable(terp) { var me = {value: 0}; return function () { ...
0
votes
0answers
53 views

Designing a scripting/programming language - translation - Javascript to C# [on hold]

So I'm making a small scripting language. I am following a tutorial online, it explains them. Now it has gotten to a part about closures, but I do not know how to do this in C# nor how I would set ...
1
vote
1answer
75 views

alternate approach of binary serialization/de-serialization

Is it possible to convert a list of object directly to byte[] (and vice versa) to gain performance (by avoiding serialization/de-serialization)? What I have in mind is that a list is somewhere in ...
0
votes
3answers
191 views

How to design an IDisposable that unconditionally needs to be disposed?

Consider a class that implements IDisposable, and that has members in such a way that it will never become eligible for garbage collection when it is not disposed. And as it will not be garbage ...
-1
votes
1answer
43 views

assembly.GetTypes() vs assembly.DefinedTypes.Select(t => t.AsType());

public static IEnumerable<Type> GetAccessibleTypes(this Assembly assembly) { try { #if NET40 return assembly.GetTypes(); #else return ...
0
votes
1answer
40 views

Modifying XML documents using deserialization/serialization VS LINQtoXML and XPATH [on hold]

I have XML documents that I need to modify, I also have the XSD schema that defines their structure. What I did was this using XSD.exe tool I create class object from the schema in program ...
0
votes
0answers
34 views

Sproc chaining verse discrete calls from OO code

I'm currently working on a change at work to generalize a function that was sloppily coded up to work for a particular use case. The function calls a particular sproc that checks if an entity exists ...
-1
votes
1answer
71 views

Word recognition in a string without spaces or punctuation marks

I have a small C# project that reads a file and gives me an output: a string that does not contain spaces nor any types of punctuation marks. It may also contain a few misspellings. Ex. Output: ...
1
vote
1answer
141 views

Are there any valid uses for the System.Collections.Specialized classes any more?

Are there any valid uses for the classes in the System.Collections.Specialized namespace any more or are they all superseded by the classes in the System.Collections.Generic, ...
0
votes
1answer
171 views

Are VB.NET and C#.NET projects created from Microsoft Visual Studio “Open Source” safe? [on hold]

I'm developing software in VB.NET and C#.NET and planning to release their source codes as fully open source. Are these projects "open-source" safe? My doubts are: VB.NET and C#.NET are using the ...
0
votes
0answers
34 views

Repository pattern & unit of work - Issue - Timeout error [migrated]

I am implemented Repository Pattern & Unit of Work after following tutorial from microsoft ...
1
vote
0answers
74 views

Are your code-first classes your domain classes? [closed]

When using Entity Framework does anyone else make a distinction between their code-first data classes (used to generate their DB) and their domain classes? If you don't, how do you reconcile the ...
0
votes
1answer
139 views

Should I use inheritance or an interface?

So in a nutshell I have an abstract class : public abstract class Member { public string PCode { get; set; } public string Reference { get; set; } public DateTime? ElectedDate { get; set; } } And ...
0
votes
2answers
90 views

Testing C# Eventhandler Subscription

I want my unit tests to be able to verify that some events were subscribed or unsubscribed at specific points. Currently, I see two options. VerifiableEventHandler Each client subscribes using the ...
1
vote
1answer
83 views

Best practice for projects architecture - server side [closed]

The usual way (that I'm familiar with) to divide the server side is the n-layer architecture : DAL - data access layer, usually has the Entities and the context (and maybe include also a repository) ...
1
vote
0answers
74 views

Patterns for Implementing Resource Expansion in ASP.NET Web API [closed]

I'd like to implement RESTful services that support Resource Expansion, so that services are self contained but if clients want to limit the number of service calls that they make, they can do so via ...
-1
votes
0answers
60 views

Entity Framework vs. Web Services [closed]

I was curious as to what the benefits of using the Entity Framework to communicate with a database directly would be versus using web services to access data. Some background: I currently work in a ...
-1
votes
0answers
38 views

Creating a DFD for the first time [closed]

I have been asked to make a dataflow diagram of a website I recently finished. I have researched it and honestly have came away with a vague understanding of what it should look like. I am going to ...
-2
votes
0answers
66 views

Define relation parent \child [on hold]

I have the following table ParentId id operator 12 13 * 12 14 * 12 15 * 12 1 - 12 ...
0
votes
0answers
36 views

SQL Permissions differ in SSMS and ASP.NET? [migrated]

I have created a schema and user called "WebAPI" which is used by ASP.NET project to get stock levels. So, I have simple stored procedure: SELECT p.ProductCode, SUM( sl.Qty ) AS 'Qty' FROM ...
0
votes
0answers
21 views

Compare data in a unknown size input file [closed]

I'm writing a time sheet calculator program to go with a time clock program I wrote. I've got the inputs coded into arrays, but I'm a bit rusty and can't figure the best way to compare the data. The ...
1
vote
1answer
105 views

How can I create a set of random numbers based on a total and number of objects?

For example with: Total population = 400000 Number of villages = 800 The average population is 500 How can I randomize the amount of people in each village using a specified deviation (eg +-50) so ...
-1
votes
1answer
80 views

Moving from windows mobile 6 to windows phone [closed]

I have been working on building applications under windows mobile for pocket Pcs for two years. now I have a large set of applications that is already built. one customer wants the same applications ...
0
votes
1answer
168 views

The problem of dependencies management

Let's consider the next situation: We have a module A which has a class Crt570 intended to interact with a device. We have a module B which uses Crt570 in the class called M100Communicator. We have ...
0
votes
1answer
63 views

A specific problem with architecturing a part of our application

Firstly, I'll try to describe the real world model of what we are trying to express in C# code. We have a device called M100. It's purpose is to read\write data from\into cards (plastic or ULTRALIGHT ...
-3
votes
0answers
57 views

Very simple sending mail application - exceptions [closed]

I would send an email from my mail adress to other mail adress. I know that here is a lot of topic about it, but I really don't know where I have mistake. What I am doing: MailAddress from = new ...
0
votes
0answers
20 views

Executing user configuration settings

For an API I'm building what it does is load an XML file that is passed to it as a string, drill to the correct element, modify values, and return the modified XML. I'm doing something like this in ...
-1
votes
0answers
50 views

Performance Difference between using ToList() vs. new List(IEnumerable<T>) [migrated]

I was curious as to the performance impact of using ToList() on an IEnumerable versus just calling the List Constructor 'List(IEnumerable)'. Example: int[] testArray = new int[10]; var list = ...
1
vote
2answers
152 views

Environment-aware Code

There are situations where the deployed environment (development, test, or production, for example) might dictate the outcome of certain actions. For example, perhaps a successful "user registration" ...
0
votes
1answer
107 views

Export to Excel - threading

I am working on an ASP.NET application. One requirement by the users is they are capable of exporting to Excel of some UIs. I have worked on them using the Infragistics library, and I have supplied ...
0
votes
0answers
155 views

Change code during runtime [migrated]

There is an old video of Notch debugging and testing his code and while doing so he simply pauses his game, makes his code modifications, and resume his game with the new changes. I found this old ...
0
votes
3answers
123 views

Storing a C# dictionary of type <datetime,enum> [closed]

As title says it, i'm looking for a way to store many dictionaries (one per user) of type Dictionary<DateTime,enum> in a database (sql server 2012). Each dictionary has 366 items inside and it ...
0
votes
2answers
109 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: ...
1
vote
1answer
172 views

Does the recent open sourcing of MSFT's C# compiler mean it can be made cross-platform? [closed]

I really enjoy working with C# however one of its biggest drawbacks is that it is kind of split-brained between MSFT .NET and Mono. In practice its not a big deal most of the time but it is one of ...
0
votes
7answers
669 views

Is there any performance benefit in checking the item count prior to executing a foreach loop?

I saw this in code and was wondering if there is any performance benefit to checking the item count prior to looping: if (SqlParams.Count > 0) foreach (var prm in SqlParams) ...
9
votes
2answers
361 views

Compile-time IOC

Has anyone started a project to do IOC at compile time (possibly using Roslyn or Linq MethodInfo emit)? My experience with IOC containers has thus far been great, baring a few small issues Many IOC ...
0
votes
2answers
153 views

How To Invoke A Method When It's Class is Accessed (Any Method) - “OnClassEnter”

I am working on a C# net micro framework project, in particular an I2C bus management/class. I have several different I2C devices each defined in separate classes which contain all of the devices' ...
1
vote
1answer
92 views

Organising data access for dependency injection

In our company we have a relatively long history of database backed applications, but have only just begun experimenting with dependency injection. I am looking for advice about how to convert our ...
0
votes
3answers
322 views

What is the main goal of MVVM pattern? [closed]

Could you tell me what is the goal of the MVVM pattern? What are the arguments or the reasons I can give to a team and product owner to respect and develop according to this pattern? I would like a ...
0
votes
0answers
19 views

Showing different forms in diff cases, and play swf file when showing [migrated]

I need your help on my application since Im new in C#. I have a form called First.cs and two others forms such as jackpot.cs and results.cs. When application runs at once start First.cs then ...