Tagged Questions

C# is a multiparadigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.

learn more… | top users | synonyms

2
votes
0answers
22 views

TryGetValue in a covariant interface

In a custom interface for keyed collections I need to implement, I want covariance. So the signature of the interface is IKeyedCollection<TKey, out TValue>. I would also like to include a method ...
8
votes
2answers
135 views

Is this a proper way of programming in c#?

I have a menu, where a user selects one out of 4, and another 2 or 4 options will appear. I used big buttons; a picturebox + label to create the buttons. The 4 main buttons are fixed, but the 4 other ...
4
votes
2answers
68 views

C# Implementing a good TCP Socket Server

public partial class ServerForm : Form { #region Fields private bool isServerRunning = false; private const int CLIENT_LIMIT = 10; private TcpListener listener; #endregion ...
4
votes
1answer
47 views

A blocking buffer manager to provide segments of a byte array

Since asynchronous operations (like Socket's Begin*-End* pairs and *Async methods) that use IOCP under the hood cause the byte array that you use as buffer to be pinned in the memory. So if you ...
2
votes
1answer
74 views

Better way to Unit Test this?

Basically I have some methods that access the file system and to avoid that in the unit test I have broken those sections out into a protected virtual method. In the Unit Test I then use Moq to setup ...
1
vote
1answer
158 views

How to optimize this C# code

The below logic is working fine. But is there any way to optimize this logic ? I have a string1, string2,...,stringn and values of each strings are string1 = "s1k1-s1k2-s1k3-....-s1kn | ...
2
votes
1answer
32 views

Simple retrieving sessionId rows from indexed SQL column is slow

I have to select all the rows from a database table containing a defined (long)sessionId where the sessionId row is indexed. But it is slow, and since the code to access it is really simple, I'm ...
6
votes
5answers
131 views

A simple unrolled linked list implementation

I tried to implement an unrolled linked list in C#. I only needed to add things and clear the whole list so I didn't implement IList<T> (I tried but it was getting too complex, so I postponed ...
2
votes
3answers
71 views

Prime numbers, Prime Factors and LCM

I am trying to generate LCM by prime factorization. I have already done the other way around to generate LCM using GCD but I am trying to achieve it using prime factorization. I am getting right ...
2
votes
2answers
39 views

Optimization code for checking if a list contains any element ID of another list

I have the following code: var sessionsWithError = SessionsFilteredByDate.Where(i => i.TrackerId > 0 && i.StatusId == 0).Select(i => i.SessionId); var ...
-1
votes
0answers
31 views

Issue with Car Physics implementation [closed]

I ported the car physics found here to java/android: http://www.gamedev.net/topic/470497-2d-car-physics-tutorial/ The problem is that when I steer it does not steer, but when I throttle it steers ...
7
votes
3answers
233 views

Can someone improve this C# code

Its working but I don't think its the best way of doing it. I also changed variable names just to let you know, string [] columnN = AnotherString.Split(','); //Another String is something ...
1
vote
0answers
68 views

Convert byte array to objects

for now in cycle I'm making Archive arch = new Archive(); int archivesize = Marshal.SizeOf(arch.GetType()); byte[] valx = new byte[archivesize]; Array.Copy(m, 2 + sizeof(int) + (archivesize * i), ...
2
votes
1answer
89 views

reusable data access class in C#

Below is my attempt at the beginnings of a reusable ado.net data access class. Please let me know of any improvements that I could make. Thanks! public class DataAccess : IDisposable { ...
3
votes
2answers
110 views

Is this FTP download code useful?

I have a Windows-service and this service will connect to an ftp server and do download, upload, and rename operations. My service runs every 30 seconds, so the ftp server will be busy during these ...

1 2 3 4 5 65
15 30 50 per page