2
votes
2answers
24 views

How to invoke a method in a class always when the class is accessed - like a reaction? [duplicate]

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

Suggest a best practice to create Constants class

There is a debate in between my team members about declaration of Constants class. We are moving the constant variables into separate class as like below public class Contants { public const ...
1
vote
2answers
210 views

Preventing some downsides of a static class

Here is my situation. I have implemented the accepted .NET 4.0 answer in this question, which is working. However, my codebase is quite large and as responsible for this code I've started getting ...
0
votes
3answers
169 views

Class or Dictionary

I want to create a immutable Scale class in C#. public sealed class Scale { string _Name; string _Description; SomeOrderedCollection _ScaleValueDefinitions; Unit _Unit // ...
0
votes
4answers
317 views

Practical Usage Of Structures in c# [duplicate]

Possible Duplicate: When do you use a struct instead of a class? While working in OOPs, we always battle around structures and classes. But in real world, we always sticks to classes. I ...
2
votes
3answers
821 views

Is there any Common Name for Edit,Save,Delete,Select

Can anyone suggest me a Common Name for Edit,Save,Delete,Select I want to create a Interface in C#, which will support all these methods. My Context is : I am developing an Invoice Application in ...
62
votes
8answers
10k views

Don't Use “Static” in C#?

I submitted an application I wrote to some other architects for code review. One of them almost immediately wrote me back and said "Don't use "static". You can't write automated tests with static ...
8
votes
4answers
2k views

Return interface or class

Suppose I have a method public List<User> GetBatchOfUsers(IEnumerable<int> userIDs) { List<User> users = new List<User>(); // some database stuff return users; } ...
0
votes
1answer
441 views

How do I start correctly in building database classes in c#?

I am new in C# programming and in OOP. I need to dive into web applications for my company, and I need to do it fast and correct. So even that I know ASP.NET MVC is the way to go, I want to start ...
0
votes
2answers
1k views

Is this a correct way to use nested classes to keep track of data?

I have some instruments. Each instrument should have a name (string) and description (string). Each instrument can have some setups, which these setups are each a series of commands(string[] or ...
24
votes
4answers
22k views

Why and when should I make a class 'static'? What is the purpose of 'static' keyword on classes?

The static keyword on a member in many languages mean that you shouldn't create an instance of that class to be able to have access to that member. However, I don't see any justification to make an ...
49
votes
5answers
21k views

When do you use a struct instead of a class?

What are your rules of thumb for when to use structs vs. classes? I'm thinking of the C# definition of those terms but if your language has similar concepts I'd like to hear your opinion as well. I ...
3
votes
2answers
1k views

Should I use a Class or Dictionary to Store Form Values

I am working on a C# .NET Application, where I have a Form with lots of controls. I need to perform computations depending on the values of the controls. Therefore, I need to pass the Form values to a ...