All Questions
1,334 questions
0
votes
0
answers
42
views
Can I use the String.Split() method overloads while splitting at white-space characters without having to specify the white-space characters? [duplicate]
I'm trying to split a string into an array of strings. I want to split at every at white-space character and also use StringSplitOptions to remove and trim the empty entries.
Is it somehow possible to ...
388
votes
33
answers
866k
views
Using C# to check if string contains a string in string array
I want to use C# to check if a string value contains a word in a string array.
For example:
string stringToCheck = "text1text2text3";
string[] stringArray = { "text1", "...
83
votes
12
answers
164k
views
int array to string
In C#, I have an array of ints, containing digits only. I want to convert this array to string.
Array example:
int[] arr = {0,1,2,3,0,1};
How can I convert this to a string formatted as: "012301"?
1
vote
1
answer
81
views
Function is not working, but gives no error
I'm new to C#. I'm trying to make game in Unity. These functions are necessary for changing in-game tabs with help of a button.
public string check;
public CanvasGroup hydrogenScreen;
public ...
7
votes
4
answers
11k
views
How to sort a string array by numeric style?
I have a filenames array, I want to sort it by numeric style, please give to me a solution.
Example1:
Original array: [name99.txt, name98.txt, name100.txt]
Sorted array: [name98.txt, name99.txt, ...
4
votes
7
answers
20k
views
Reading ini file in C#
I am trying to read an ini file that has the following format:
SETTING=VALUE
SETTING2=VALUE2
I currently have the following code:
string cache = sr.ReadToEnd();
string[] ...
0
votes
4
answers
120
views
How to concat various chunks of string array based on a condition
Lets say i have a string array like this,
string[] array1 = {
"<p>here is a big sentence</p>",
"file1",
"file2",
"<p>this is a big ...
0
votes
3
answers
56
views
C# Putting an Array in to a String Backward
I have an Array which I filled up.
Now the problem I have is I want to put the array together in to one string but starting from the end of the Array.
while(Opsplitser > -1)
{
EindResultaat = ...
0
votes
4
answers
13k
views
C# best way to convert object to string array
I am stuck in something.
I want to convert this object, which is a array of objects, into a array of strings I cannot find a good way to do that. Do I need to use a for loop? If someone can also tell ...
1
vote
1
answer
148
views
Find errors: Array - wrong output
I'm writing string[] to show multiple rows in the output. A stupid question, why the output is not 5 x 5?(I used i and j both from 0-4, then the ouput should be an array 5 x 5), can anyone help?
<...
0
votes
0
answers
80
views
C# array of string not nullable but init with null string[] arrayOfString = new string[2];
Working with VS2022 and .NET 8 with <Nullable>Enabled</Nullable> for my project.
I encounter null pointer exception at run time with the following code:
string[] arrayOfString = new string[...
-1
votes
1
answer
72
views
Check if any value from Array1 Contains any value from Array2
How can I check if a value from an Array Contains any value from an other Array ?
For example:
string[] array1 = {"1726KB12","271","MB192"}
string[] array2 = {"KB&...
-3
votes
4
answers
10k
views
How to Initialize, assign and return a string array in c#
I'm trying to fit the below code in one of my projects. But it throws an error while assigning string to an array. Can you please tell me what did I do wrong?
Public string[] ReturnStringArray()
{
...
2
votes
3
answers
2k
views
Turn string into string array for command-line arguments
I have string with the following format:
"arg1" "arg2" "arg3" ... "argx"
I am going to use this string as the string[] for my program's command-line arguments.
How can I turn this string into a ...
-3
votes
1
answer
68
views
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in c# from a string array [closed]
string[] user = { "a" } , pass ={ "a" };
string check1, check2;
string TBTOS;
bool correct = false;
int howmanyusers = 0;
howmanyusers++;
...