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
0answers
27 views

Windows custom lockscreen program [on hold]

I'd like to create a windows application that locks my screen, I want the program to have the same functionality as this program but I want to add functionality to it so I can play custom sounds and ...
0
votes
1answer
53 views

Domain Object class design?

This kind is a continuation of a question i had yesterday. I was incorrectly trying to pass data for that class into the constructor which caused IOC containers to not work effectively. I was advised ...
0
votes
1answer
43 views

Extensions on Visual Studio 2015 Express [on hold]

I used to install some extensions on VS Express 2013. We were using it to create some internal tools, one of them was Web Essentials. I wanted to start using VS Express 2015 so I could use the new C# ...
4
votes
3answers
215 views

How can I add properties to subclasses and access them without casting from a superclass?

I'm trying to model a multi-dimensional point class in C#. I have about eight different types of points, and there may be more in the future. Right now, I have a superclass (PointBase) that holds all ...
4
votes
1answer
104 views

Dependency Management in the real world?

Most of the examples i've see when watching anything on dependency management hit what i consider to be the holy grail in that the only dependencies on classes are interfaces that the IOC container ...
2
votes
0answers
60 views

How do I test with multiple input combinations?

I have a piece of code that I need to test, which is layered in three parts: Web API Controller Persistence/Logic Layer System calls for persistence It's the basic GET/POST/PUT/DELETE call system. ...
17
votes
3answers
2k views

Class with members that are mutable during creation but immutable afterwards

I have an algorithm which creates a collection of objects. These objects are mutable during creation, since they start out with very little, but then they are populated with data in different places ...
11
votes
3answers
1k views

Why does C# have both out and ref?

C# have out and ref, why these two are required. I don't have depth knowledge of C#. Why out and ref parameters are required?
1
vote
0answers
56 views

Could there be a use case for C# style auto-properties in Python

I've been doing a lot of work in C# recently (my primary language is Python) and I love that I can do something like public string MyProperty{ get; set; } Going back to Python I miss that sort of ...
0
votes
0answers
32 views

Building a house automation server [on hold]

My current project involves house automation with extensive use of media. I am now tasked with programming a central control server. This server will take input via an android application and other ...
-2
votes
0answers
17 views

XML (de)serialization invalid characters in c#? [on hold]

I have a person class with CDataContent and it may have invalid XML characters. So have created a class to help the (de)serialization, however it does not handle the XML Invalid characters in ...
-1
votes
0answers
4 views

(C#) sending hex over serial [migrated]

So I'm trying to send a (string?) of hex that looks like this "7E 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 FF" over a serial port. My code looks like this: serialport.write("7E 00 00 FF 00 00 ...
0
votes
2answers
76 views

How can I show and hide a single field across my web application through a checked value?

Let's say I have a field called "FooName" and I have "FooName" in several places across my web application (ASP.NET MVC4). I have a check box that allows me to turn "FooName" on and off across the ...
-5
votes
0answers
31 views

Desktop application to access HTML files [closed]

I am planning to design a desktop application which will access an HTML file,take data from it, then store the data after some logic in excel. I have some queries regarding that. Which language can ...
4
votes
2answers
69 views

Need sorting method for coordinated, flattenned collection

I have a component which outputs an ICollection of the following type: public class CoordinatedInjectableValue { public int XOffset { get; set; } public int YOffset { get; set; } public ...
0
votes
3answers
316 views

i++ vs i+=1 in cycles, why evaluate? [on hold]

Why do most programmers use i++ in cycles? Doesn't it mean evaluate and increment. I find more logical to use just an increment i+=1, because that's all I want. WriteLn(i++); would evaluate i and ...
0
votes
0answers
31 views

SignalR UI updates and group managing

I'm working on a web application and I have 2 specific questions regarding SignalR I need give the UI real-time updates (both broadcast to everybody on the hub, but also just to the original caller) ...
-1
votes
0answers
64 views

Why does internal instance become null [migrated]

I am trying to figure out why the assigner (myC.myself) become null after the line is compiled? Thanks in advance. namespace AequalsBequalsC { class Program { static void Main(string[] args) ...
-4
votes
0answers
39 views

What should I do if “velocity can't be used like a method”? [closed]

I was working in c# and I typed this line: if (Input.GetKeyDown (KeyCode.Space)) { GetComponent<Rigidbody2D>().velocity (0, jumpheight); } My computer then said that velocity can't be ...
0
votes
0answers
11 views

Integrating legacy application with new functionality

We have a legacy application with, among other things, the ability to create instances classes within VB6 DLLs dynamically and call methods with varying signatures. We have no way of accessing the ...
19
votes
4answers
4k views

How do I handle setters on immutable fields?

I have a class with two readonly int fields. They are exposed as properties: public class Thing { private readonly int _foo, _bar; /// <summary> I AM IMMUTABLE. </summary> ...
1
vote
3answers
138 views

Design pattern for different code behaviors according to different clients

At my company, we have a solution composed of a WinForm (multiple per client) and an API (one per client). This solution is deployed on different clients that require the solution to behave ...
2
votes
1answer
61 views

Is there a standard way to handle assigning and managing tasks for users/groups in asp.net?

Take for example what I would assume to be a fairly standard process flow, where certain users are assigned a role which allows them to create requests, but another group (or subset) are assigned a ...
4
votes
2answers
114 views

Entity Framework Domain Object as Business Object

If I am not concerned with unit testing and switching my data access out at a later time, would using my entity framework objects as my business objects be okay? I have an existing database for which ...
1
vote
1answer
31 views

How to model table and column objects and their relation

I'm working on a small application where I need to model tables and columns from a relational DB. I've been reading some material on nested classes, which is recommended to be used sparsely. However ...
4
votes
4answers
116 views

Instantiating class that contains methods to check some of the settings and also return values from my app.config file

I am writing a console application and have a class called ApplicationConfiguration that contains methods to check some of the settings and also return values from my app.config file. For instance ...
0
votes
0answers
71 views

Any “Gotchas” to using Entity Framework for Identity & Dapper for all other DB access in a .NET MVC application?

I'm firing up an MVC project in which I'd really like to use Dapper as my ORM, as I like to be as close to the database as possible for performance and SQL tweaking reasons, yet still have the power ...
3
votes
1answer
90 views

Best practice for buffering when posting to a web-service that has gone offline

If I am collecting data that needs to be posted to a web service on a regular (~5 minutes) basis, and that service has temporarily gone offline, what is the best practice to ensure we don't lose any ...
4
votes
1answer
161 views

Control Start Of Program

I made a program, which was supposed to run every night as a windows scheduled task, let's say the program is just one method, called Do_Task(). Usually you need to press a button to run the Do_Task() ...
1
vote
1answer
37 views

How to model a time-based m-to-n relationship in Entity Framework using code first

I have to model and manage a time-based configuration. Typically - without an OR mapper - I would start with the database tables. Screen Color ColorScreenMapping ------------- ...
-1
votes
0answers
23 views

Multiple publishers to one subscriber: handling subscribing and unsubscribing [migrated]

I hope this isn't too general, so I apologize in advance if so. I am creating a console text adventure game. I essentially have many monsters, one per room at the moment. I also have a God ...
1
vote
2answers
145 views

Convert this abstract class to an interface

I have a security method I would like to be able to sprinkle into other classes throughout my program. It is currently an abstract class but I feel it would be more appropriate as an interface. Can ...
5
votes
1answer
109 views

Hot-patching a server: dynamically loading types from an uploaded assembly

In the current project I'm working on, some of the C# classes are being stored as source code in SQL Server database records, and executed as needed using CSScript. This is being done so that the ...
2
votes
2answers
65 views

Authenticate in the Services? Or in an Endpoint that exposes the Services?

When I'm in charge, I typically model services separate from endpoints. For example: Company.Project.Domain.dll has all of the logic required to complete the services for that domain. In order to ...
-4
votes
1answer
66 views

Text adventure: how to incorporate pet system which allows pet to hunt? [closed]

The question I have is on how to best implement a feature. Currently I am creating a console text adventure game. It's a project I've been working on for a while now, and due to it being my first C# ...
0
votes
1answer
55 views

Issues deciding on approach to create object

I'm trying to decide what's the best approach to instantiate a particular class. Basically there are two use cases for it: instantiate it in order to save a new entry to the database and fetch an ...
4
votes
3answers
1k views

Is the question “What is the using statement” a bad question to ask an interviewee? [closed]

We're looking to hire a new junior C# developer. We're not looking for guru's or anything, so my boss asked me to write down a few questions and answers of varying difficulty to assess their skills. ...
1
vote
2answers
245 views

Is there a name for this pattern?

A while loop can be written as follows in C# (and many other languages): int someValue; int someTerminatingValue; while ((someValue = GetSomeValue()) != someTerminatingValue) { // Do something ...
1
vote
1answer
46 views

What are the differences regarding speed and functionality between using Actions vs Delegates?

I know this is a language specific question and may not be suitable here but I would like to create an array of functions that will be called based on their index and I would like to know the ...
1
vote
0answers
41 views

How to write class libraries that work with DB

I have programmed a library in C#, which process some EDI into meaningful data based on the DB structure of a table. I have used a typed dataset in the class library project. Now I run into an issue ...
2
votes
1answer
104 views

Is Static a code-smell that is frequently bad? And if so, isn't AOP inherently smelly? [closed]

I'm working with my experience that static-anything is a code smell. Obviously static is a powerful and useful tool in our toolbox. But if I Ctrl+F static in a novice or sometimes even seasoned ...
2
votes
1answer
91 views

In C#, is it good practice to use implicit numeric conversions from int to float?

For example: if(5.0f > 1) { } Does it have a significant performance penalty? Compared to just doing if(5.0f > 1.0f) { }
1
vote
1answer
74 views

Pattern for communicating between nested usercontrols and parent form (C# / Winforms)

I'm trying to decide the best way to handle communication between a UserControl that is nested within another UserControl and the parent Form itself. I have a Form, inside the form there's a ...
0
votes
1answer
102 views

Will TDD really save bug fixing time for WPF/MVVM

I'm looking for an update .net 4.5 WPF+MVVM+TDD tutorial for my team. I have found only one good tutorial https://deltaengine.fogbugz.com/?W199 My goal is to learn Test Driven Development using WPF ...
6
votes
4answers
275 views

Can I make my constructors less repetitive?

I'm extending a class with 10 different constructors. The new subclass, SpecialImage, is used like this: SpecialImage specialImage = new SpecialImage(..); // Leverage the Rotate() method of ...
2
votes
1answer
79 views

How to implement role permissions in service layer?

In my current project i have Report class and i am going to implement service layer for it. Every method will be allowed only for some roles. Like this. public class ReportService : IReportService { ...
22
votes
8answers
2k views

Should my (sequential) collection start at index 0 or index 1?

I am creating an object model for a device that has multiple channels. The nouns used between the client and I are Channel and ChannelSet. ("Set" isn't semantically accurate, because it's ordered ...
3
votes
3answers
228 views

Can you do iterative development in c#? [closed]

I'm primarily a Python/R developer. In those languages, the way I develop is to sketch out a data and class structure, write the methods and their tests in interactive mode, then refactor them up into ...
0
votes
1answer
99 views

How to access a variable that I only need to create once on Application.Start

According to this guide: https://github.com/mspnp/azure-guidance/blob/master/Retry-Service-Specific.md They say: Note that the StackExchange.Redis client uses multiplexing through a single ...
0
votes
0answers
37 views

Implementing a Dynamic Network Message Dispatcher/Handler

I have a current requirement of an application to handle messages of different types, subtypes, and possibly more subtypes, as deep as needed. These messages come off the network and should be shared ...