2
votes
1answer
109 views

Too slow two strings comparer

I have 2 strings for example: abcabc and bcabca or aaaabb and abaaba I checked that second string is the same or not like first string but shifted. bcabca = ..abca + bc... Here is code it works ...
3
votes
1answer
69 views

A reliable way to remove consecutive appearances of a substring

I'm attempting to write a piece of code that is supposed to remove consecutive appearances of a string (not a single character) in a StringBuilder. It's extremely important that the method works well ...
4
votes
3answers
270 views

Longest common substring

I wrote a program to find the longest common subsequence among several strings. I used a naive algorithm and implementation. The motivation was solving the Rosalind problem at ...
2
votes
1answer
121 views

Inefficient usage of string.format?

I have some sample code where I used string.Format but after reading about benchmark performances by other people I believe that it may be better to do multiple appends by a StringBuilder Here is the ...
8
votes
2answers
205 views

String join of distinct string

I have a class like this one: class EmailClass { public string MailAdresse { get; set; } public string MailAdresseCC { get; set; } } Through a JSON deserialization I obtain a ...
7
votes
1answer
92 views

Can I use string.Format to represent these formatted numbers more succinctly?

string taskNumber = order.ID.ToString("D6") + "-" + task.ID.ToString("D4"); I'm writing out two numbers separated with a dash. The first number is padded with leading zeros until 6 digits, the ...
8
votes
3answers
343 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
1answer
525 views

Parsing XML to create IList

Here's a class I created to parse XML to create an IList. It seems to me that this is something that will be done a lot in general by a lot of different programs. Is there a more standard way of doing ...
4
votes
4answers
207 views

Title case name when first,middle and last are all upper or lower case

This code works, but i get the feeling that it could be shorter and simpler. Any ideas? private void CheckNameCase(Models.PersonalInformationModels.PersonalInformationModel model) { // if first ...
1
vote
2answers
989 views

Can this algorithm to find substring in string be further improved?

static int find(string term, string text) { int found = -1; int termIndex = 0; for (int textIndex = 0; textIndex < text.Length; textIndex++) { if ...
0
votes
1answer
595 views

Manipulate XML files in c#

I just finished my working code, but still want to improve it. I want to transform this input: <item>asdf</item> <item>asdf</item> <item>asdf</item> to this ...
1
vote
2answers
308 views

Messy c# code - can be improved? String Parsing

For various reasons, I'm parsing a string, this code will explain what I'm after: string baseString = "This is a \"Very Long Test\""; string[] strings = baseString.Split(' '); ...
3
votes
2answers
361 views

“String Enum” implementation - comments?

I have a need to represent a finite set of discrete string values: When these strings are used in code, they must belong to the valid set, or serious errors (or worse) can occur. As "magic ...
1
vote
1answer
364 views

Extending string mapping

Basically I'm trying to generalise and extend the notion of mapping one string into another. There are two methods I often find myself using for this: Functions, and Dictionairies. So here are my 3 ...
7
votes
3answers
275 views

Reusing strings read from I/O

I am working on an application that reads lots of data from the network and puts it in a grid. I noticed that I could save some memory by reusing existing strings instead of always using the new ...

1 2
15 30 50 per page