Tagged Questions
0
votes
3answers
19 views
Check if string consists only of valid ISO 8859-1 characters
How to check if a string consists only of chars, which can be successfully encoded in ISO 8859-1? Or in other words - how to find "illegal"/"not ISO 8859-1 compatible" chars in a string?
7
votes
1answer
65 views
string.Join - “cannot convert from IEnumerable to string[]”
Very simple extension method not compiling:
public static string Join(this string text, params string[] stringsToJoin)
{
return String.Join(", ", stringsToJoin.Where(s => ...
0
votes
5answers
40 views
A new array out of some values from existing array
If I got an array like:
string[] test = new string[5] { "hello", "world", "test", "world", "world"};
How can I make a new array out of the ones that is the same string, "world" that is where you on ...
2
votes
3answers
103 views
C# linq object[] to string [duplicate]
This rather inelegant method takes an input array of objects and outputs a string result, which is the result of ToString() for each element, space separated.
string Format(object[] args)
{
var ...
-1
votes
2answers
36 views
Need help on a method
i just started learning c# and i am trying to make a console application that will read a text file and show it on the command prompt. I am also trying to make the method that reads the text file in a ...
2
votes
4answers
66 views
Comparing two strings with different orders
I have a dictionary with a list of strings that each look something like:
"beginning|middle|middle2|end"
Now what I wanted was to do this:
List<string> stringsWithPipes = new ...
0
votes
3answers
49 views
Replace single chars in string at position x [duplicate]
I am doing a simple hangman game. I have gotten everything going except for the part where the user enters a correct char and the corresponding char in the solution word should be replaced with the ...
-4
votes
4answers
67 views
C# “or” operator
I have this code:
if (textBox1.Text == "one" || "two")
I have tried to use || and | to add more strings, but it says that it cannot be applied to operands of type "bool" and "string". How can I ...
0
votes
2answers
35 views
Special symbols in string c#
I receive json from server: response: {text: 'Rize – The Orchid (Original Mix)'}
and after JsonConvert.DeserializeObject<JSonR>(responseFromServer);
and get "Rize &_ndash;(without ...
1
vote
6answers
56 views
Extracting an unknown string between two known strings
I have the following string:
string nextEvent = "[[\"nextData\", \"RANDOM MESSAGE\"], [\"moreInfo\", {\"num\": 3204}]]"
I need to get "RANDOM MESSAGE" (without the quotes) into a seperate string. ...
0
votes
5answers
61 views
Compare two lists of strings of varying length for difference based on content, not length
I have two lists, imported and existing. They can be of the same length, or of different length.
I want to check if there's anything in imported that's not in existing.
If they're the same length, ...
3
votes
5answers
100 views
Converting byte array to string in C# [duplicate]
Is there an easy way to convert a byte array to a string so the following unit test passes? I can't find an encoding that works for all values.
[TestMethod]
public void TestBytToString()
{
...
1
vote
2answers
44 views
split string by character and add to different columns in DataGridView in c#
I have this code :
string strdata = Encoding.Unicode.GetString(buffer);
char[] splitchar = new Char[] { '\x00' };
string[] assetdata = strdata.Split(splitchar, strdata.Length);
Buffer is a text ...
2
votes
2answers
53 views
Match up everything before STRING or STRING
I've searched for hours and already tried tons of different patterns - there's a simple thing I wan't to achive with regex, but somehow it just won't do as I want:
Possible Strings
String1
This ...
4
votes
8answers
123 views
Better way for the special concatenation of two strings
I want to concatenate two strings in such a way, that after the first character of the first string, the first character of second string comes, and then the second character of first string comes and ...