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
35 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 ...
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 ...
0
votes
2answers
41 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 ...
-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 . ...
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
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 ...
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
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 ...
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 ...
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 ...
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
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 ...
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
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
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 ...
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
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# ...
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 ...
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
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 ...
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 ...
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 ...
0
votes
4answers
116 views

What is the preferred way to hold a file over multiple requests in MVC

I am building a wizard and the first step of this wizard is to let the user select a file. In the following steps I need this file to display some data from it and as a final step I have to import ...
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 ...
0
votes
2answers
90 views

Track a series of choices with a single number

I want to track a series of scored questions in a single number (the total score). Is that possible? and how? For example, I have 30 questions with either 3 or 2 choices. For any given question, the ...
3
votes
2answers
205 views

Using reflection vs creating a new class

I and a friend are having an argument on what is the better technique to use in the following scenario: An application we need to test has a number of components (lets call them Eggs); each component ...
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 ...
-1
votes
4answers
92 views

Adding non distinct elements to a dictionary

Suggestions on a good pattern to follow to add elements to a dictionary where you want to add an element if it does not exist, else do nothing The 2 approaches I can think of are ...
1
vote
1answer
194 views

Efficiency of C# dictionaries

C# dictionaries are a simple way to find if something exists etc etc. I have a question though on how they work. Let's say instead of a dictionary I use an ArrayList. Instead of using ContainsKey (or ...
-3
votes
0answers
30 views

How to use a JOIN SQL statement in ASP.NET using Access? [migrated]

OK so I am a programming student with a headache that hopefully someone will be able to cure. I am currently creating a website using ASP.NET in Microsoft Visual Studio for a project and here is my ...
-1
votes
0answers
37 views

how to convert system.linq.IQueryable<int?> to int?[] [migrated]

foreach (var app in allList) { int?[] ids = Context.tblTransactionDetails .Where(x => x.IsActive == true) .Select(x => x.AdvertID); }
9
votes
5answers
2k views

Which are the cases when 'uint' and 'short' datatypes are a better fit than the standard int(32)?

I understand the differences in capacity and values they can represent but it seems as though people always use Int32 regardless of whether it is appropriate. No one ever seems to use the unsigned ...
3
votes
5answers
722 views

Creating a sort of 'in-language compiler'

I'm not saying I want to create a whole new compiler that's completely independent. I'm using C# Windows Forms and I want users to be able to write filtering syntax in a textbox withing my managed ...
0
votes
1answer
62 views

Is automatic conversion to collection types from non-collection variable a good idea? [closed]

Consider public void Do(string[] aBunchOfStrings) { } or public void Do(IReadOnlyList<string> aBunchOfStrings) { } Would it be a bad idea to allow the function call Do("woei"); resolve ...
0
votes
3answers
105 views

Various methods manipulating same member variable versus each takes inputs and provides output [closed]

As software design paradigm which is better? to let various methods manipulate a member variable, or define each method or function to take some inputs and provide some outputs? For example class ...
-4
votes
0answers
31 views

How to export multiple resumes (created by gridview in html format) [migrated]

First of all I want to convert the resume bound with grid to a .doc file. I HAVE used the following code. But the problem is that it export only 1 resume to Word doc. I have to allow the client to ...
3
votes
1answer
132 views

Usage of this keyword in constructor chaining?

I am reading msdn documentation for this keyword. They gave three usages for this keyword as follows To qualify members hidden by similar names To pass an object as a parameter to other methods To ...
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 ...
-1
votes
3answers
156 views

Cleaner C# without unneeded indents [closed]

In OO languages, at least C#, everything has to be in a class. Sometimes, everything is in a namespace as well. Just about literally all the code in one class is going to be automatically indented ...
0
votes
2answers
162 views

if a c# interface contain only getter and setter definition, is it a code smell?

A project that I am working on has the following code for interface example: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test { public ...
0
votes
0answers
47 views

Totalising and condensing data values from multiple arrays into a single array [migrated]

My fledgling programming skills have hit a wall. I could get this working, but the code stinks and I'm convinced there must be a more efficient way I just don't know it yet. I have a web service ...
0
votes
3answers
163 views

Using action array vs Switch Case [closed]

I have an occasion of code in which I will draw a different set of buttons in a screen (depending on the number of the buttons). One thought (and my current implementation) is to use an action array ...
38
votes
10answers
5k views

Should I accept empty collections in my methods that iterate over them?

I have a method where all logic is performed inside a foreach loop that iterates over the method's parameter: public IEnumerable<TransformedNode> TransformNodes(IEnumerable<Node> nodes) { ...
0
votes
2answers
175 views

Bad Practice using Auto Generated Classes for Data Access

I've seen this before but haven't found concrete reasons. When you add Entities to your EF model, EF auto generates classes for these entities. In terms of DataAccess, why is it preferred to not ...
0
votes
1answer
85 views

Async properties in interfaces to cater for the possibility of expensive first-time evaluation: Is this a good idea?

First of all, sorry if this post is too long. I'll start with the… Short version: Is it generally advisable or a good idea to design an interface property as asynchronous simply because we cannot be ...