All Questions
1,334 questions
1186
votes
16
answers
1.6m
views
How to convert UTF-8 byte[] to string
I have a byte[] array that is loaded from a file that I happen to known contains UTF-8.
In some debugging code, I need to convert it to a string. Is there a one-liner that will do this?
Under the ...
538
votes
8
answers
527k
views
.NET / C# - Convert char[] to string
What is the proper way to turn a char[] into a string?
The ToString() method from an array of characters doesn't do the trick.
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", "...
346
votes
5
answers
328k
views
Convert array of integers to comma-separated string
It's a simple question; I am a newbie in C#, how can I perform the following
I want to convert an array of integers to a comma-separated string.
I have
int[] arr = new int[5] {1,2,3,4,5};
I want to ...
304
votes
13
answers
383k
views
How to access random item in list?
I have an ArrayList, and I need to be able to click a button and then randomly pick out a string from that list and display it in a messagebox.
How would I go about doing this?
243
votes
9
answers
483k
views
convert string array to string
I would like to convert a string array to a single string.
string[] test = new string[2];
test[0] = "Hello ";
test[1] = "World!";
I would like to have something like "Hello World!"
211
votes
10
answers
604k
views
Check if a value is in an array (C#)
How do I check if a value is in an array in C#?
Like, I want to create an array with a list of printer names.
These will be fed to a method, which will look at each string in turn, and if the string ...
210
votes
11
answers
409k
views
C# declare empty string array
I need to declare an empty string array and i'm using this code
string[] arr = new String[0]();
But I get "method name expected" error.
What's wrong?
203
votes
13
answers
554k
views
Checking if a string array contains a value, and if so, getting its position
I have this string array:
string[] stringArray = { "text1", "text2", "text3", "text4" };
string value = "text3";
I would like to determine if stringArray contains value. If so, I want to locate its ...
145
votes
4
answers
357k
views
Convert an array to string
How do I make this output to a string?
List<string> Client = new List<string>();
foreach (string listitem in lbClients.SelectedItems)
{
Client.Add(listitem);
}
121
votes
10
answers
187k
views
Is string in array?
What would be the best way to look in a string[] to see if it contains a element. This was my first shot at it. But perhaps there is something that I am overlooking. The array size will be no larger ...
114
votes
3
answers
50k
views
Opposite of String.Split with separators (.net)
Is there a way to do the opposite of String.Split in .Net? That is, to combine all the elements of an array with a given separator.
Taking ["a", "b", "c"] and giving "a b c" (with a separator of " ")....
107
votes
3
answers
83k
views
How can I safely convert a byte array into a string and back? [duplicate]
I don't really care about encoding and stuff, as long as I get back the exact same byte array.
So to sum up: How do I convert a byte array into a string, and then that string back into the same byte ...
103
votes
3
answers
227k
views
Split and join C# string [duplicate]
Possible Duplicate:
First split then join a subset of a string
I'm trying to split a string into an array, take first element out (use it) and then join the rest of the array into a seperate ...
97
votes
2
answers
113k
views
Newtonsoft.Json.Linq.JArray to string array C#
I have a JSON Array like
model.Users = ["Joe","Barny","Power","Tester"]
the model is dynamic
I want to convert model.Users to string[] Users
string[] Users = model.Users
How can I do that?