Tagged Questions
C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
0
votes
0answers
11 views
2
votes
0answers
50 views
Two similar methods to process a queue of messages
I have two functions with loops that behave nearly identically, but with some key differences. As a consequence, most (but not all!) of the code in the functions is repeated. I can accept this ...
2
votes
0answers
47 views
Delimited file parser
This is some code I've cobbled together that reads a delimited file. If the user is able to tell us some stuff about the file, it uses the supplied information. Otherwise, it tries to work stuff out ...
4
votes
3answers
323 views
Simple Q&A game
I just wanted to get some criticism on my programming to make me better. I made a game in Unity, just a simple question and answer game.
Demo
...
2
votes
1answer
54 views
Can this runtime compiler code be faster
I've been playing about with runtime compilation to allow me to get/set runtime property values in C# and so far I have come up with the class as the bottom of the question.
This allows me to write ...
0
votes
2answers
82 views
Create an array with random numbers
private static byte[] GenerateData(long size)
{
var result = new byte[size];
new Random().NextBytes(result);
return result;
}
Is it good, robust and ...
0
votes
1answer
40 views
Map a hierarchy of nested DTO objects to a list of business objects [on hold]
Consider I download my data into this data structures:
...
7
votes
2answers
458 views
Evaluating Parser State
The "parser state" of a module in rubberduck can be one of several values:
...
2
votes
2answers
35 views
Calculate GS1 / SSCC / UPC check digit
I try to write a function which calculates the check digit for shipping label based on the algorithm provided by GS1
http://www.gs1.org/how-calculate-check-digit-manually
Version 1: my first try
...
0
votes
0answers
39 views
C# - Separating construction and initialization when serializing a class [on hold]
I am currently working on a method to have custom control over the way my classes are serialized. All serializable classes have an interface and they all serialize themselves to an intermediate class ...
-2
votes
5answers
107 views
Finding dice roll results in a combinable list of numbers
This code takes a selection of numbers between 1 to 9 which could be 1,2,3,4,5,6,7,8,9 or 1,2,4 or ...
4
votes
2answers
76 views
Stitching Linq with if blocks
I recently learned about Linq's deferred execution and a little clearer understanding of IEnumerable. I came back to some code that I had written and decided to change with Linq extension methods. ...
7
votes
4answers
447 views
C# SMTP notifier client
I've come from a PHP background and I'm really trying to unlearn the bad habits I acquired from not doing things properly with PHP through my own lack of understanding..
I'm looking to advance my ...
0
votes
1answer
70 views
Storing data bytes into properties
From the related questions here, I've found this and this answers, both of which suggest Replacing Conditional with Polymorphism, are probably what I'm looking for. However, I'm not sure if ...
0
votes
4answers
114 views
Remove “b” and “ac” from a given string
I coded this solution for this problem:
Given a string, eliminate all “b” and “ac” in the string, you have to replace them in-place, and you are only allowed to iterate over the string once
Seems to ...
1
vote
1answer
18 views
Copy Data from Informix to SQL Server
The following method copies data from Informix db to SQL Server db and it's so slow, I want to refactor it so it could be more readable and faster:
...
1
vote
0answers
35 views
An Extended WebBrowser Control
I needed the ability to do a few extra things with a WebBrowser control on a .NET Windows Forms Form, and I found it needed some updates.
So, I made a few. I added ...
-3
votes
0answers
22 views
C# Weather App Not Working [on hold]
I'm making a weather program that seems like it should work but when I press the button the text in the label doesn't even change. I removed my API key for security.
...
4
votes
1answer
61 views
Implementing Binary Tree using Queue in C#
I am in the process of learning data structures and I am trying to implement Binary Tree using Queue in C#.
Below are my Tree implementation classes.
...
3
votes
0answers
47 views
Genetic algorithm to arrange rooms in a house
I am an architecture thesis student in my final year and I am developing a piece of software that, ideally, should design houses for me based on certain input.
I got the program to work when it was ...
2
votes
2answers
98 views
Take a result set and organize it into a dictionary
I'm trying to take a result set and organize it into a dictionary then assign the dictionary values to variables that are publicly accessible from my controller. My issue is I have to check if there ...
-4
votes
0answers
19 views
Multiple XML data in datagridview [closed]
My query to a large Xml Database
var query = DOC.Descendants("entry").Where(f => f.Element("url").Value.Contains("example"));
returns multiple xml Data
I ...
6
votes
2answers
314 views
Generic extension method that will attempt to parse a string and return it's value or default(T)
So I got sick of several things about the way TryParse works. I implemented a generic ParseOrDefault function using reflection. It appears to work as expected, but I'm not fool enough to say my code ...
-2
votes
1answer
42 views
Iterate through a table object to get subobjects [closed]
I have various examples of getting a grid/table data
For example I get in personId,CourseId sorted order
PersonId, PersonName,Email, CourseId,CourseName
I then need to for example email it.
...
2
votes
1answer
75 views
C# data class with public auto-implemented properties with constructor that specifies each
I have a dll and an executable which both deal in configuring certain things for a much broader software solution, and the code below in particular is directly meant for database configuration. (Here ...
3
votes
0answers
36 views
MSTest Data Driven Test Inline Data
Background:
Didn't what to have to reference bulky 3rd party lib for inline data driven tests and wanted to use standard MS testing framework.
Created helper ...
1
vote
2answers
86 views
Iterating over thousands of objects to generate html
Currently I am working on a profiling unit that does not require stack traces to preserve the call stack, and can return the performance in a html format.
All though the logging in itself is fairly ...
3
votes
2answers
74 views
Add item after every nth step
The purpose of the method is to add a list of items after every nth step (5 for example) where the input items are repeated if needed. I'm looking for an overall review and possible how to remove the ...
0
votes
0answers
8 views
Wrapping A Long List of Parameters as a Single Object [migrated]
Consider the following interface:
...
2
votes
1answer
26 views
Internal function that determines when to resize by width or height in a Image Resizer utility
I'm open to any suggestion.
Variables/methods names, the use (or lack of) { and } on ...
4
votes
1answer
106 views
VERY simple C# Set implementation
This is not meant to solve any insane real world problems. I just want to make sure my Set logic is right and the code looks okay. It feels weird implementing it with a ...
9
votes
3answers
1k views
Simple C# HashTable Implementation
Haven't put one of these together since college. How does this look overall?
...
4
votes
2answers
56 views
Creating a device configuration
During the test process of a device, there is a procedure that sets a device in a state in which it is ready to be tested (typically by writing default measure parameters, 3G connection parameters and ...
3
votes
1answer
36 views
Azure cloud page blob stream
A custom stream that is used to perform read and write operations directly into the page cloud blob
...
6
votes
2answers
124 views
Expose a IDbSet<> object to overcome a limitation for LINQ's Select()
TL/DR: I have a Get() method which exposes a IDbSet<> object to overcome a limitation for LINQ's Select(). Is it considered leaky?
Long Post:
Hi everyone. Before posting this I have spent the ...
6
votes
2answers
204 views
First program: a simple calculator
I'm reading this very good book, C# Player's Guide, to learn C#. I then plan to make video games with Unity 3D after.
In one of the chapters, he asks us to make a (really) simple calculator as a ...
5
votes
5answers
679 views
Handle IDisposable objects
When I work a lot with objects, that implements IDisposable I am using this pattern, like shown here with a SqlConnection and a SqlCommand.
...
2
votes
1answer
50 views
Implementing an array backed list
I post the below code as review/answer to a question in codereview.
(Custom Dynamic Array)
however, seems the answer itself having issues looking at the comments that I received.
I would appreciate ...
0
votes
3answers
66 views
Datagridview filter with BindingSource
I want to perform a filter on a DataGridView using 3 different TextBox.
The solution below works, but does not consider very ...
4
votes
1answer
69 views
An extension to the StringBuilder
This is another pretty basic class I wrote for a library as I hate the way the default StringBuilder in .NET works.
Essentially, I wanted to have the ...
0
votes
1answer
67 views
Data model decomposition into key value pairs using reflection and attributes
I'm trying to change how our system generates PDF files. Currently I have a class for each PDF that goes through the model for the PDF and fills in the properties. I want to change that to a self ...
-4
votes
0answers
56 views
I need this simple code to run faster - C# [closed]
Ok, so I have to make an program that will make integer array better quality (the quality is determined by it's smallest variable). I have been given a amount of consecutive elements that I can ...
-2
votes
0answers
15 views
How to Code Obstacle to Go Back Into My Object Pooler When They Collide With a Boundary? [closed]
please do not feel intimidated by my long question, I am sure I just worded it weird lol. I followed Mike Geig's excellent tutorial on using Object Pooling in Unity, and I get the concept pretty well. ...
3
votes
1answer
77 views
Checking winning conditions in a Connect Four game
I'm trying to refactor this C# code that uses one true brace style (it's enforced). I'm coming to C# from C++, in the former I could've made x and ...
0
votes
1answer
74 views
Custom Dynamic Array
Pretty simple class but just want to make sure I've approached it correctly.
...
2
votes
1answer
85 views
C# console roulette game
I made a C# console roulette game. Check it out and give opinions on how to improve or ideas for some other features? It's not finished yet so it has lots of room for improvement. I am very new so ...
2
votes
0answers
41 views
Generic Unrolled Linked List with IList<T> interface implementation
I was inspired by the Phillip Trelford "Beyond Lists" presentation published on InfoQ. So, I decided to make it simple, yet still capable to act as IList<T>.
...
-4
votes
1answer
55 views
Multithreaded AES encryption [closed]
I am trying to implement Lowering speed on my hybride encryption function for large files but can't seems to successfully bug fix a few issues.
How do I deal with the while loop in this ...
1
vote
2answers
63 views
Project Euler #44
I'm having trouble optimizing my code for the exercise in Project Euler #44
Pentagonal numbers are generated by the formula, \$P_n=\frac{n(3n−1)}{2}\$. The first ten pentagonal numbers are:
...
0
votes
1answer
37 views
Detecting cycle in LinkedList
Is this a fair/clean way to detect a cycle in a LinkedList? Should work for both single and double LinkedLists'.
...