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
7answers
657 views

Would an “as 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 ) { // It's B, go for it ...
0
votes
0answers
13 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 ...
0
votes
3answers
59 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 ...
2
votes
1answer
68 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
47 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 ...
3
votes
1answer
189 views

modelling a restaurant availability search

I am looking into finding an efficient way which can scale up to thousands of restaurants, for doing a reservation search. Ideally, it would be efficient to answer queries like find a restaurant ...
2
votes
2answers
177 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
234 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
39 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
24 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
159 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
52 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 ...
4
votes
5answers
414 views

How to go about training IComparable to a team?

I (am just a developer) am tasked with training my team on a technique or technology. I zeroed upon System Interfaces, IComparable and IEquatable to be specific. How does one go about teaching (even ...
0
votes
3answers
187 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
vote
1answer
68 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 ...
-1
votes
1answer
42 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
7answers
666 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) ...
0
votes
1answer
38 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 ...
0
votes
3answers
321 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 ...
-1
votes
1answer
69 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
0answers
74 views

Are your code-first classes your domain classes? [on hold]

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 ...
1
vote
1answer
140 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
169 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 ...
5
votes
2answers
874 views

Are there any good examples of open source C# projects with a large number of refactorings? [on hold]

I'm doing research into software evolution and C#/.NET, specifically on identifying refactorings from changesets, so I'm looking for a suitable (XP-like) project that may serve as a test subject for ...
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 ...
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 ...
0
votes
1answer
138 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 ...
1
vote
0answers
74 views

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

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
vote
1answer
83 views

Best practice for projects architecture - server side [on hold]

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) ...
32
votes
3answers
1k views

Does Java development typically involve more subclassing than C#/.NET?

I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly ...
9
votes
2answers
360 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 ...
-1
votes
0answers
59 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
36 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
2answers
106 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
248 views

Syncing objects from code with the view in WPF

I've been reading some into it, but I am time pressed, so I would require a simple solution now and I promise to read up on it later. I come from a winforms c# background, and have lately been working ...
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 ...
0
votes
1answer
105 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 ...
1
vote
5answers
358 views

Unit Testing a method that contains two output type parameters

I was following a book Art of Unit Testing, This book says that You must not have any logic in Your asserts as this reduces readability of test, or I may be testing too many things at a time. Suppose ...
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 ...
1
vote
1answer
104 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
79 views

Moving from windows mobile 6 to windows phone [on hold]

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 ...
-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 = ...
0
votes
1answer
262 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 { ...
1
vote
1answer
150 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
0answers
55 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
1answer
62 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 ...
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 ...